-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(uploader): images should display when they've been successfully uploaded #2448
Changes from 1 commit
093aa6c
a584452
cd248b5
213158f
2620d3f
6e203f6
ace0192
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,7 +166,6 @@ | |
clearUploadQueue() | ||
}, | ||
})) | ||
|
||
const clearUploadQueue = (index = -1) => { | ||
if (index > -1) { | ||
uploadQueue.splice(index, 1) | ||
|
@@ -202,27 +201,27 @@ | |
uploadOption.onStart = (option: UploadOptions) => { | ||
clearUploadQueue(index) | ||
setFileList( | ||
fileList.map((item) => { | ||
[...fileList, fileItem].map((item) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 请添加测试以覆盖新代码。 根据静态分析工具的警告,这一行新增的代码没有被测试覆盖。 ToolsGitHub Check: codecov/patch
|
||
if (item.uid === fileItem.uid) { | ||
item.status = 'ready' | ||
item.message = locale.uploader.readyUpload | ||
} | ||
return item | ||
}) | ||
) | ||
onStart && onStart(option) | ||
onStart?.(option) | ||
Alex-huxiyang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
uploadOption.onProgress = ( | ||
e: ProgressEvent<XMLHttpRequestEventTarget>, | ||
option: UploadOptions | ||
) => { | ||
setFileList( | ||
fileList.map((item) => { | ||
[...fileList, fileItem].map((item) => { | ||
Alex-huxiyang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (item.uid === fileItem.uid) { | ||
item.status = UPLOADING | ||
item.message = locale.uploader.uploading | ||
item.percentage = ((e.loaded / e.total) * 100).toFixed(0) | ||
onProgress && onProgress({ e, option, percentage: item.percentage }) | ||
onProgress?.({ e, option, percentage: item.percentage }) | ||
Alex-huxiyang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return item | ||
}) | ||
|
@@ -232,7 +231,7 @@ | |
responseText: XMLHttpRequest['responseText'], | ||
option: UploadOptions | ||
) => { | ||
const list = fileList.map((item) => { | ||
const list = [...fileList, fileItem].map((item) => { | ||
Alex-huxiyang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (item.uid === fileItem.uid) { | ||
item.status = SUCCESS | ||
item.message = locale.uploader.success | ||
|
@@ -293,7 +292,6 @@ | |
fileItem.message = autoUpload | ||
? locale.uploader.readyUpload | ||
: locale.uploader.waitingUpload | ||
|
||
executeUpload(fileItem, index) | ||
|
||
if (preview && file.type?.includes('image')) { | ||
|
@@ -319,9 +317,7 @@ | |
} | ||
return true | ||
}) | ||
if (oversizes.length) { | ||
onOversize && onOversize(files) | ||
} | ||
oversizes.length && onOversize?.(files) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 请添加测试以覆盖新代码。 根据静态分析工具的警告,这一行新增的代码没有被测试覆盖。 ToolsGitHub Check: codecov/patch
|
||
|
||
if (filterFile.length > maximum) { | ||
filterFile.splice(maximum, filterFile.length - maximum) | ||
|
@@ -367,8 +363,6 @@ | |
readFile(_files) | ||
} | ||
|
||
setFileList(fileList) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 关注一下数据源的处理位置是否有异常。 |
||
|
||
if (clearInput) { | ||
clearInputValue($el) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请考虑为新代码添加测试。
根据以前的学习记忆,当
fileList
状态有变更时,需要确保有相应的单元测试覆盖。需要帮助生成单元测试代码或在GitHub上跟踪此任务吗?