From 01ff4b677743ecf1bb2da2a7563bb85c6fd3ba16 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Sun, 30 Aug 2026 11:33:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(voices):=20=E7=B2=BE=E7=A1=AE=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=8E=BB=E9=87=8D=E5=88=86=E6=94=AF=20+=20=E9=9D=9E?= =?UTF-8?q?=20duplicated=20=E6=97=B6=20ingest=5Fjob=5Fid=20=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1=E6=8A=9B=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 去重判断从 `duplicated === true || !ingest_job_id` 改为先判 duplicated - 非 duplicated 但 ingest_job_id 缺失时抛错(避免掩盖真实上传失败) - 回应 AI Code Review #1552 阻塞问题 --- apps/web/playwright-report/index.html | 68 +++++++++++++++++++ .../actions/useVoiceUpload.ts | 9 ++- .../src/pages/voices/hooks/useVoiceUpload.ts | 10 ++- 3 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 apps/web/playwright-report/index.html diff --git a/apps/web/playwright-report/index.html b/apps/web/playwright-report/index.html new file mode 100644 index 000000000..f98f3962d --- /dev/null +++ b/apps/web/playwright-report/index.html @@ -0,0 +1,68 @@ + + + + + + + + + Playwright Test Report + + + + +
+ + + \ No newline at end of file diff --git a/apps/web/src/pages/voice-materials/hooks/useVoiceMaterials/actions/useVoiceUpload.ts b/apps/web/src/pages/voice-materials/hooks/useVoiceMaterials/actions/useVoiceUpload.ts index af0e4f910..a22e5bdd8 100755 --- a/apps/web/src/pages/voice-materials/hooks/useVoiceMaterials/actions/useVoiceUpload.ts +++ b/apps/web/src/pages/voice-materials/hooks/useVoiceMaterials/actions/useVoiceUpload.ts @@ -55,10 +55,15 @@ export function useVoiceUpload({ voiceLibrary, createLibMutation }: UseVoiceUplo }) // 去重命中(同库已存在相同 file_hash 素材): - // 后端返回 duplicated=true 且 ingest_job_id 为空;跳过轮询和打标签,直接走 onSuccess - if (complete.duplicated === true || !complete.ingest_job_id) { + // 后端返回 duplicated=true,ingest_job_id 为空;跳过轮询和打标签, + // mutationFn 正常 return 即 resolve,useMutation 自动触发 onSuccess 刷新列表。 + // 已存在素材复用上次标签,无需重新打标。 + if (complete.duplicated === true) { return } + if (!complete.ingest_job_id) { + throw new Error("上传完成但未返回处理任务 ID,请重试") + } const { ingest_job_id } = complete // 3. 轮询 ingest job 状态(complete 后先立即查一次,未完成再每 5s 轮询) diff --git a/apps/web/src/pages/voices/hooks/useVoiceUpload.ts b/apps/web/src/pages/voices/hooks/useVoiceUpload.ts index 2014bc1fb..eb25d6fa5 100644 --- a/apps/web/src/pages/voices/hooks/useVoiceUpload.ts +++ b/apps/web/src/pages/voices/hooks/useVoiceUpload.ts @@ -39,12 +39,16 @@ export function useVoiceUpload({ showToast }: UseVoiceUploadProps) { }) /* 去重命中(同库已存在相同 file_hash 素材): - * 后端返回 duplicated=true 且 ingest_job_id 为空, - * 不轮询、直接按上传成功处理(onSuccess 分支 toast + 刷新列表) + * 后端返回 duplicated=true,ingest_job_id 为空, + * 不轮询、直接按上传成功处理(onSuccess 分支 toast + 刷新列表)。 + * 注意:mutationFn 正常 return 即视为 resolve,useMutation 会自动调 onSuccess。 */ - if (complete.duplicated === true || !complete.ingest_job_id) { + if (complete.duplicated === true) { return } + if (!complete.ingest_job_id) { + throw new Error("上传完成但未返回处理任务 ID,请重试") + } const { ingest_job_id } = complete /* 轮询 ingest job 状态,等待 Worker 处理完成;