Skip to content

Commit

Permalink
fix(upload): 只有多个上传请求同时触发时才需 onOneFileFail (#1652)
Browse files Browse the repository at this point in the history
  • Loading branch information
xixileng authored Oct 19, 2022
1 parent 0800adf commit 6e00739
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/upload/hooks/useUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,19 @@ export default function useUpload(props: TdUploadProps, context: SetupContext) {
const onResponseError = (p: OnResponseErrorContext) => {
if (!p || !p.files || !p.files[0]) return;
const { response, event, files } = p;
updateFilesProgress();
const params: UploadFailContext = {
e: event,
file: files?.[0],
currentFiles: files,
failedFiles: files,
response,
};
props.onOneFileFail?.(params);
context.emit('one-file-fail', params);
// 只有多个上传请求同时触发时才需 onOneFileFail
if (props.multiple && !props.uploadAllFilesInOneRequest) {
updateFilesProgress();
const params: UploadFailContext = {
e: event,
file: files?.[0],
currentFiles: files,
failedFiles: files,
response,
};
props.onOneFileFail?.(params);
context.emit('one-file-fail', params);
}
// 单选或多文件替换,需要清空上一次上传成功的文件
if (!props.multiple || props.isBatchUpload) {
setUploadValue([], {
Expand Down

0 comments on commit 6e00739

Please sign in to comment.