From b02c75347ea650813209f8234c9da0bb5159ddbf Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 21 Jun 2026 22:23:14 -0700 Subject: [PATCH] =?UTF-8?q?fix(web-antdv-next):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=AF=8C=E6=96=87=E6=9C=AC=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RichEditor 图片上传改用 uploadFile(data, onUploadProgress) 真实签名,不再把 onProgress/onSuccess/onError 塞进请求体。 URL 提取逻辑保持 response?.data?.url ?? response?.url ?? '' 不变。 --- .../src/adapter/component/index.ts | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/apps/web-antdv-next/src/adapter/component/index.ts b/apps/web-antdv-next/src/adapter/component/index.ts index 846473793..74f89517d 100644 --- a/apps/web-antdv-next/src/adapter/component/index.ts +++ b/apps/web-antdv-next/src/adapter/component/index.ts @@ -740,22 +740,18 @@ async function initComponentAdapter() { Rate, RichEditor: withDefaultPlaceholder(VbenTiptap, 'input', { imageUpload: { - upload: (file: any, onProgress: any) => { - return new Promise((resolve, reject) => { - uploadFileApi({ - file, - onProgress({ percent }) { - onProgress?.(percent); - }, - onSuccess(response) { - // 从响应中提取图片URL - resolve(response?.data?.url ?? response?.url ?? ''); - }, - onError() { - reject(new Error($t('ui.tiptap.upload.uploadFailed'))); - }, + upload: async (file: File, onProgress?: (percent: number) => void) => { + try { + const response = await uploadFileApi({ file }, (progressEvent) => { + const percent = progressEvent.total + ? Math.round((progressEvent.loaded * 100) / progressEvent.total) + : 0; + onProgress?.(percent); }); - }); + return response?.data?.url ?? response?.url ?? ''; + } catch { + throw new Error($t('ui.tiptap.upload.uploadFailed')); + } }, }, }),