fix: 多张大图并行上传时不再拆掉进行中的请求,并放宽附件上传超时。
审批附件在第一张成功后会重建上传组件,其余请求被取消并显示超时。现保留进行中的文件,附件请求与 Nginx 上传超时放宽到 5 分钟,存储写入不再堵住事件循环。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
50d56ce0bb
commit
8020e667f1
17 files changed
+10070
-9831
No files matched your search
@@ -6,7 +6,6 @@
|
||||
<div class="_fc-upload _oa-fc-upload">
|
||||
<el-upload
|
||||
ref="uploadRef"
|
||||
:key="fileCount"
|
||||
v-bind="uploadAttrs"
|
||||
:list-type="resolvedListType"
|
||||
:class="{ '_fc-exceed': isExceed }"
|
||||
@@ -230,6 +229,8 @@
|
||||
return {
|
||||
previewVisible: false,
|
||||
previewImage: '',
|
||||
/** 进行中的上传次数。大于 0 时不要用 modelValue 覆盖 fileList,否则会拆掉仍在上传的文件 */
|
||||
uploadInflight: 0,
|
||||
fileList: [] as Array<UploadUserFile & { is_string?: boolean; value?: unknown }>
|
||||
}
|
||||
},
|
||||
@@ -269,6 +270,9 @@
|
||||
modelValue: {
|
||||
immediate: true,
|
||||
handler(n: unknown) {
|
||||
// 多文件并行时,第一个成功会改 modelValue。若此时整表替换,
|
||||
// Element Plus 会丢掉仍在上传的项,并在销毁后的实例上读 uid 抛错。
|
||||
if (this.uploadInflight > 0) return
|
||||
this.fileList = toArray(n).map(parseFile).map(parseUpload)
|
||||
}
|
||||
}
|
||||
@@ -338,6 +342,32 @@
|
||||
upload?.handleRemove?.(file)
|
||||
},
|
||||
doHttpRequest(option: UploadRequestOptions) {
|
||||
this.uploadInflight += 1
|
||||
let settled = false
|
||||
const finish = () => {
|
||||
if (settled) return
|
||||
settled = true
|
||||
this.uploadInflight = Math.max(0, this.uploadInflight - 1)
|
||||
if (this.uploadInflight === 0) {
|
||||
this.fileList = toArray(this.modelValue).map(parseFile).map(parseUpload)
|
||||
}
|
||||
}
|
||||
const prevSuccess = option.onSuccess
|
||||
const prevError = option.onError
|
||||
option.onSuccess = (res: any) => {
|
||||
try {
|
||||
prevSuccess?.(res)
|
||||
} finally {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
option.onError = (err: any) => {
|
||||
try {
|
||||
prevError?.(err)
|
||||
} finally {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
if (typeof this.httpRequest === 'function') {
|
||||
return this.httpRequest(option)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user