From 9f978cc9b0aab4e48e88d37dc828c67331a38cd0 Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Wed, 30 Apr 2025 14:13:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=A8=E6=9D=A5=E6=A0=87=E8=AF=86?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E4=B8=BA=E4=B8=8A=E4=BC=A0=20=E8=BF=99?= =?UTF-8?q?=E6=A0=B7=E5=9C=A8watch=E5=86=85=E9=83=A8=E4=B8=8D=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E8=AF=B7=E6=B1=82api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/components/upload/src/hook.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/web-antd/src/components/upload/src/hook.ts b/apps/web-antd/src/components/upload/src/hook.ts index a45cd858..938114df 100644 --- a/apps/web-antd/src/components/upload/src/hook.ts +++ b/apps/web-antd/src/components/upload/src/hook.ts @@ -160,6 +160,8 @@ export function useUpload( return undefined; } + // 用来标识是否为上传 这样在watch内部不需要请求api + let isUpload = false; function handleChange(info: UploadChangeParam) { /** * 移除当前文件 @@ -199,7 +201,8 @@ export function useUpload( currentFile.fileName = transformFilename(cb); currentFile.name = transformFilename(cb); currentFile.thumbUrl = transformThumbUrl(cb); - + // 标记为上传 watch根据值做处理 + isUpload = true; // ossID添加 单个文件会被当做string if (props.maxCount === 1) { bindValue.value = ossId; @@ -321,6 +324,14 @@ export function useUpload( if (value.length === 0) { return; } + + // 上传完毕 不需要调用获取信息接口 + if (isUpload) { + // 清理 使下一次状态可用 + isUpload = false; + return; + } + const resp = await ossInfo(value); function transformFile(info: OssFile) { const cb = { type: 'info', response: info } as const;