fix(frontend): pass {size} param to fileSizeExceeded i18n on Nginx 413

The Nginx 413 error handler in request.ts calls t('error.fileSizeExceeded')
without the required {size} parameter, causing the toast to display
"文件大小不能超过 M!" instead of "文件大小不能超过 50M!".

Export MAX_FILE_SIZE_MB from utils/index.ts and pass it as {size} to the
i18n call, matching the sibling call site in kbFileTypeVerification().
This commit is contained in:
jackson.jia
2026-06-04 15:53:29 +08:00
committed by lyingbug
parent dda16436d0
commit 10383c6ddd
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ declare global {
// 从运行时配置获取最大文件大小(MB),支持 Docker 环境动态配置
// 优先级:运行时配置 > 构建时环境变量 > 默认值 50MB
const MAX_FILE_SIZE_MB = window.__RUNTIME_CONFIG__?.MAX_FILE_SIZE_MB
export const MAX_FILE_SIZE_MB = window.__RUNTIME_CONFIG__?.MAX_FILE_SIZE_MB
|| Number(import.meta.env.VITE_MAX_FILE_SIZE_MB)
|| 50;
const MAX_FILE_SIZE_BYTES = MAX_FILE_SIZE_MB * 1024 * 1024;
+2 -2
View File
@@ -1,6 +1,6 @@
// src/utils/request.js
import axios from "axios";
import { generateRandomString } from "./index";
import { generateRandomString, MAX_FILE_SIZE_MB } from "./index";
import i18n from '@/i18n'
import { getApiBaseUrl } from './api-base';
@@ -185,7 +185,7 @@ instance.interceptors.response.use(
if (error.response.status === 413) {
return Promise.reject({
status: 413,
message: t('error.fileSizeExceeded'),
message: i18n.global.t('error.fileSizeExceeded', { size: MAX_FILE_SIZE_MB }),
success: false
});
}