fix(web-antdv-next): 修复富文本图片上传适配
RichEditor 图片上传改用 uploadFile(data, onUploadProgress) 真实签名,不再把 onProgress/onSuccess/onError 塞进请求体。 URL 提取逻辑保持 response?.data?.url ?? response?.url ?? '' 不变。migration
parent
6608d297e2
commit
b02c75347e
|
|
@ -740,22 +740,18 @@ async function initComponentAdapter() {
|
||||||
Rate,
|
Rate,
|
||||||
RichEditor: withDefaultPlaceholder(VbenTiptap, 'input', {
|
RichEditor: withDefaultPlaceholder(VbenTiptap, 'input', {
|
||||||
imageUpload: {
|
imageUpload: {
|
||||||
upload: (file: any, onProgress: any) => {
|
upload: async (file: File, onProgress?: (percent: number) => void) => {
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
uploadFileApi({
|
const response = await uploadFileApi({ file }, (progressEvent) => {
|
||||||
file,
|
const percent = progressEvent.total
|
||||||
onProgress({ percent }) {
|
? Math.round((progressEvent.loaded * 100) / progressEvent.total)
|
||||||
onProgress?.(percent);
|
: 0;
|
||||||
},
|
onProgress?.(percent);
|
||||||
onSuccess(response) {
|
|
||||||
// 从响应中提取图片URL
|
|
||||||
resolve(response?.data?.url ?? response?.url ?? '');
|
|
||||||
},
|
|
||||||
onError() {
|
|
||||||
reject(new Error($t('ui.tiptap.upload.uploadFailed')));
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
return response?.data?.url ?? response?.url ?? '';
|
||||||
|
} catch {
|
||||||
|
throw new Error($t('ui.tiptap.upload.uploadFailed'));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue