From 2099e6467fd083419afed367e90419b0e3ac3824 Mon Sep 17 00:00:00 2001 From: cycleccc <2991205548@qq.com> Date: Wed, 25 Dec 2024 12:03:15 +0800 Subject: [PATCH] fix(upload): implement complete upload callback for improved file handling --- .changeset/rich-waves-argue.md | 6 ++++++ packages/core/src/upload/createUploader.ts | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .changeset/rich-waves-argue.md diff --git a/.changeset/rich-waves-argue.md b/.changeset/rich-waves-argue.md new file mode 100644 index 000000000..3e3fcb823 --- /dev/null +++ b/.changeset/rich-waves-argue.md @@ -0,0 +1,6 @@ +--- +"@wangeditor-next/core": patch +"@wangeditor-next/editor": patch +--- + +fix(upload): add complete upload callback diff --git a/packages/core/src/upload/createUploader.ts b/packages/core/src/upload/createUploader.ts index 2ec967104..ad70a05cd 100644 --- a/packages/core/src/upload/createUploader.ts +++ b/packages/core/src/upload/createUploader.ts @@ -67,11 +67,13 @@ function createUploader(config: IUploadConfig): Uppy { }) // 各个 callback - uppy.on('upload-success', (file, response) => { - const { body = {} } = response + // onSuccess 每个 file 上传成功都会触发,改用 complete 便于 files 上传 + uppy.on('complete', result => { + const file = result.successful[0] + const { response } = file + const { body = {} } = response ?? {} try { - // 有用户传入的第三方代码,得用 try catch 包裹 onSuccess(file, body) } catch (err) { console.error('wangEditor upload file - onSuccess error', err)