From 62202b7eff4cd7242f3f8da3e3633e58920ea50c Mon Sep 17 00:00:00 2001 From: balibabu Date: Tue, 1 Oct 2024 16:37:46 +0800 Subject: [PATCH] fix: Fixed the issue where no error message was displayed when uploading a file that was too large #2258 (#2697) ### What problem does this PR solve? fix: Fixed the issue where no error message was displayed when uploading a file that was too large #2258 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- web/src/locales/en.ts | 1 + web/src/locales/zh-traditional.ts | 1 + web/src/locales/zh.ts | 1 + web/src/utils/request.ts | 6 ++++++ 4 files changed, 9 insertions(+) diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index c555babfdd..e776bb6d50 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -604,6 +604,7 @@ The above is the content you need to summarize.`, 404: 'The request was made for a record that does not exist, and the server did not perform the operation.', 406: 'The requested format is not available.', 410: 'The requested resource has been permanently deleted and will not be available again.', + 413: 'The total size of the files uploaded at once is too large.', 422: 'When creating an object, a validation error occurred.', 500: 'A server error occurred, please check the server.', 502: 'Gateway error.', diff --git a/web/src/locales/zh-traditional.ts b/web/src/locales/zh-traditional.ts index 6982472796..872b27e541 100644 --- a/web/src/locales/zh-traditional.ts +++ b/web/src/locales/zh-traditional.ts @@ -563,6 +563,7 @@ export default { 404: '發出的請求針對的是不存在的記錄,服務器沒有進行操作。', 406: '請求的格式不可得。', 410: '請求的資源被永久刪除,且不會再得到的。', + 413: '上傳的檔案總大小太大', 422: '當創建一個對象時,發生一個驗證錯誤。', 500: '服務器發生錯誤,請檢查服務器。', 502: '網關錯誤。', diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts index 30b06e7a4b..6dc70338be 100644 --- a/web/src/locales/zh.ts +++ b/web/src/locales/zh.ts @@ -580,6 +580,7 @@ export default { 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。', 406: '请求的格式不可得。', 410: '请求的资源被永久删除,且不会再得到的。', + 413: '上传的文件总大小过大。', 422: '当创建一个对象时,发生一个验证错误。', 500: '服务器发生错误,请检查服务器。', 502: '网关错误。', diff --git a/web/src/utils/request.ts b/web/src/utils/request.ts index 675a3dbd70..2627362bd4 100644 --- a/web/src/utils/request.ts +++ b/web/src/utils/request.ts @@ -22,6 +22,7 @@ const RetcodeMessage = { 404: i18n.t('message.404'), 406: i18n.t('message.406'), 410: i18n.t('message.410'), + 413: i18n.t('message.413'), 422: i18n.t('message.422'), 500: i18n.t('message.500'), 502: i18n.t('message.502'), @@ -39,6 +40,7 @@ type ResultCode = | 404 | 406 | 410 + | 413 | 422 | 500 | 502 @@ -97,6 +99,10 @@ request.interceptors.request.use((url: string, options: any) => { }); request.interceptors.response.use(async (response: any, options) => { + if (response?.status === 413) { + message.error(RetcodeMessage[413]); + } + if (options.responseType === 'blob') { return response; }