refactor: replace PostgREST calls in upload page with new API endpoints
- getDocumentTypes: switch from PostgREST /document_types to GET /api/document-types - getTodayDocuments: switch from PostgREST /documents to GET /api/documents/list with userId + dateFrom params - getQueueStatus: gracefully handle 404 (endpoint not yet migrated) by returning empty queue state instead of erroring
This commit is contained in:
+13
-2
@@ -50,10 +50,21 @@ export async function getQueueStatus(): Promise<{ data?: QueueStatus; error?: st
|
||||
|
||||
return { data: response.data };
|
||||
} catch (error) {
|
||||
console.error('【队列状态】获取队列状态失败:', error);
|
||||
// 队列接口暂未迁移,404 时返回空状态不报错
|
||||
if (axios.isAxiosError(error) && error.response?.status === 404) {
|
||||
return {
|
||||
data: {
|
||||
success: true,
|
||||
timestamp: new Date().toISOString(),
|
||||
queue: { pending_tasks: 0, processing_tasks: 0, available_slots: 0, max_concurrent: 4 },
|
||||
documents: { waiting: 0, processing: 0, processing_ids: [] },
|
||||
},
|
||||
};
|
||||
}
|
||||
console.error("【队列状态】获取队列状态失败:", error);
|
||||
if (axios.isAxiosError(error)) {
|
||||
return { error: error.response?.data?.detail || error.message };
|
||||
}
|
||||
return { error: error instanceof Error ? error.message : '获取队列状态失败' };
|
||||
return { error: error instanceof Error ? error.message : "获取队列状态失败" };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user