return error state if upload file size exceeds limit
This commit is contained in:
parent
0b18c15347
commit
8a2048af22
20
unitool.js
20
unitool.js
@ -321,8 +321,14 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!fileSize) {
|
if (!fileSize) {
|
||||||
this.showToast({ type: this.c2t.YELLOW, title: this.localizeText({ zhCN: '文件为空,无法上传', enUS: 'Empty files cannot be uploaded' }) })
|
let _msg = { zhCN: '文件为空,无法上传。', enUS: 'Empty files cannot be uploaded.' }
|
||||||
return { _state: 'CER_EMPTY_FILE' }
|
this.showToast({ type: this.c2t.YELLOW, title: this.localizeText(_msg) })
|
||||||
|
return { _state: 'CER_EMPTY_FILE', _msg }
|
||||||
|
} else if (fileSize > (globalThis.wo?.envar?.fileSizeLimit || 10485760)) {
|
||||||
|
let sizeLimitMB = parseInt((globalThis.wo?.envar?.fileSizeLimit || 10485760) / 1048576) + 'MB'
|
||||||
|
let _msg = { zhCN: `文件太大了,无法上传。最大允许 ${sizeLimitMB}`, enUS: `File too large to upload. Maximum allowed is ${sizeLimitMB}` }
|
||||||
|
this.showToast({ type: this.c2t.YELLOW, title: this.localizeText(_msg) })
|
||||||
|
return { _state: 'CER_FILE_TOO_LARGE', _msg }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
@ -421,8 +427,14 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!fileSize) {
|
if (!fileSize) {
|
||||||
this.showToast({ type: this.c2t.YELLOW, title: this.localizeText({ zhCN: '文件为空,无法上传', enUS: 'Empty files cannot be uploaded' }) })
|
let _msg = { zhCN: '文件为空,无法上传。', enUS: 'Empty files cannot be uploaded.' }
|
||||||
return { _state: 'CER_EMPTY_FILE' }
|
this.showToast({ type: this.c2t.YELLOW, title: this.localizeText(_msg) })
|
||||||
|
return { _state: 'CER_EMPTY_FILE', _msg }
|
||||||
|
} else if (fileSize > (globalThis.wo?.envar?.fileSizeLimit || 10485760)) {
|
||||||
|
let sizeLimitMB = parseInt((globalThis.wo?.envar?.fileSizeLimit || 10485760) / 1048576) + 'MB'
|
||||||
|
let _msg = { zhCN: `文件太大了,无法上传。最大允许 ${sizeLimitMB}`, enUS: `File too large to upload. Maximum allowed is ${sizeLimitMB}` }
|
||||||
|
this.showToast({ type: this.c2t.YELLOW, title: this.localizeText(_msg) })
|
||||||
|
return { _state: 'CER_FILE_TOO_LARGE', _msg }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
|
Loading…
Reference in New Issue
Block a user