From 10383c6ddd679d99b2eae14cedb13a4723e29c77 Mon Sep 17 00:00:00 2001 From: "jackson.jia" Date: Thu, 4 Jun 2026 15:53:29 +0800 Subject: [PATCH] fix(frontend): pass {size} param to fileSizeExceeded i18n on Nginx 413 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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(). --- frontend/src/utils/index.ts | 2 +- frontend/src/utils/request.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index fe44bc16..baf0db9e 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -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; diff --git a/frontend/src/utils/request.ts b/frontend/src/utils/request.ts index 7b2c5181..bbdd146c 100644 --- a/frontend/src/utils/request.ts +++ b/frontend/src/utils/request.ts @@ -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 }); }