fix(frontend): 补重试解析状态刷新
This commit is contained in:
@@ -8,8 +8,8 @@ import {
|
||||
chunkRagDocuments,
|
||||
deleteRagDocument,
|
||||
getRagDocumentById,
|
||||
parseRagDocuments,
|
||||
queryRagDocuments,
|
||||
retryParseRagDocuments,
|
||||
saveRagDocument,
|
||||
RAG_CHUNK_STRATEGY,
|
||||
type RagChunkStrategy,
|
||||
@@ -116,6 +116,45 @@ async function loadDocs() {
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshParseProgress(documentIds: string[]) {
|
||||
if (documentIds.length === 0) {
|
||||
return;
|
||||
}
|
||||
let rounds = 0;
|
||||
while (rounds < 6) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 1500));
|
||||
await loadDocs();
|
||||
const targetDocs = docRows.value.filter((row) => documentIds.includes(String(row.id ?? '')));
|
||||
const allDone = targetDocs.every((row) => row.parseStatus === 'PARSED' || row.parseStatus === 'FAILED');
|
||||
if (allDone) {
|
||||
return;
|
||||
}
|
||||
rounds += 1;
|
||||
}
|
||||
}
|
||||
|
||||
function markRowsParsing(documentIds: string[]) {
|
||||
if (documentIds.length === 0) {
|
||||
return;
|
||||
}
|
||||
const idSet = new Set(documentIds);
|
||||
docRows.value = docRows.value.map((row) => {
|
||||
if (!idSet.has(String(row.id ?? ''))) {
|
||||
return row;
|
||||
}
|
||||
return {
|
||||
...row,
|
||||
parseStatus: 'PARSING',
|
||||
errorMessage: null,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async function handleUploaded(documentIds: string[]) {
|
||||
await loadDocs();
|
||||
await refreshParseProgress(documentIds);
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
loadDocs();
|
||||
}
|
||||
@@ -262,9 +301,11 @@ async function retryParseRows(rows: RagDocument[]) {
|
||||
}
|
||||
retryParsing.value = true;
|
||||
try {
|
||||
await parseRagDocuments({ documentIds: ids });
|
||||
await retryParseRagDocuments({ documentIds: ids });
|
||||
markRowsParsing(ids);
|
||||
ElMessage.success('已提交解析重试任务');
|
||||
await loadDocs();
|
||||
await refreshParseProgress(ids);
|
||||
} finally {
|
||||
retryParsing.value = false;
|
||||
}
|
||||
@@ -504,7 +545,7 @@ onMounted(() => {
|
||||
v-model="uploadDialogVisible"
|
||||
:stores="storeOptions"
|
||||
:locked-store-id="queryForm.storeId || null"
|
||||
@uploaded="loadDocs"
|
||||
@uploaded="handleUploaded"
|
||||
/>
|
||||
|
||||
<el-dialog
|
||||
|
||||
Reference in New Issue
Block a user