From efbd8e9bd10047e0be9c22bc8667ac31410d0a5e Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Tue, 20 Jan 2026 11:08:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(upload):=20=E4=BF=AE=E5=A4=8D=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=8D=B8=E8=BD=BD=E6=97=B6=E6=9C=AA=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E4=B8=AD=E6=AD=A2=E6=89=80=E6=9C=89=E4=B8=8A=E4=BC=A0=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将单个AbortController改为存储多个中止函数,确保所有上传请求都能在组件卸载时被正确中止 --- apps/web-antd/src/components/upload/src/hook.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/web-antd/src/components/upload/src/hook.ts b/apps/web-antd/src/components/upload/src/hook.ts index ddda6c5c..bc1acb46 100644 --- a/apps/web-antd/src/components/upload/src/hook.ts +++ b/apps/web-antd/src/components/upload/src/hook.ts @@ -271,7 +271,7 @@ export function useUpload( return file; }; - const uploadAbort = new AbortController(); + const abortList: (() => void)[] = []; /** * 自定义上传实现 * @param info @@ -291,6 +291,7 @@ export function useUpload( const percent = Math.trunc((e.loaded / e.total!) * 100); info.onProgress!({ percent }); }); + abortList.push(apiInstance.abort); const res = await apiInstance; info.onSuccess!(res); if (props.showSuccessMsg) { @@ -304,7 +305,8 @@ export function useUpload( }; onUnmounted(() => { - props.abortOnUnmounted && uploadAbort.abort(); + props.abortOnUnmounted && abortList.forEach((abort) => abort()); + abortList.length = 0; }); /**