diff --git a/unitool.js b/unitool.js index 28fcb5c..3816cd1 100644 --- a/unitool.js +++ b/unitool.js @@ -321,8 +321,14 @@ export default { } if (!fileSize) { - this.showToast({ type: this.c2t.YELLOW, title: this.localizeText({ zhCN: '文件为空,无法上传', enUS: 'Empty files cannot be uploaded' }) }) - return { _state: 'CER_EMPTY_FILE' } + let _msg = { zhCN: '文件为空,无法上传。', enUS: 'Empty files cannot be uploaded.' } + 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) { @@ -421,8 +427,14 @@ export default { } if (!fileSize) { - this.showToast({ type: this.c2t.YELLOW, title: this.localizeText({ zhCN: '文件为空,无法上传', enUS: 'Empty files cannot be uploaded' }) }) - return { _state: 'CER_EMPTY_FILE' } + let _msg = { zhCN: '文件为空,无法上传。', enUS: 'Empty files cannot be uploaded.' } + 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) {