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,
|
||||
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'));
|
||||
}
|
||||
},
|
||||
},
|
||||
}),
|
||||
|
|
|
|||
Loading…
Reference in New Issue