feat: 支持运行时动态配置文件大小限制

This commit is contained in:
wizardchen
2026-01-05 10:45:54 +08:00
committed by lyingbug
parent 1b0edccfc4
commit 20e7b36202
5 changed files with 39 additions and 8 deletions
+14 -2
View File
@@ -1,7 +1,19 @@
import { MessagePlugin } from "tdesign-vue-next";
// 从环境变量获取最大文件大小(MB),默认30MB
const MAX_FILE_SIZE_MB = Number(import.meta.env.VITE_MAX_FILE_SIZE_MB) || 50;
// 声明全局运行时配置类型
declare global {
interface Window {
__RUNTIME_CONFIG__?: {
MAX_FILE_SIZE_MB?: number;
};
}
}
// 从运行时配置获取最大文件大小(MB),支持 Docker 环境动态配置
// 优先级:运行时配置 > 构建时环境变量 > 默认值 50MB
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;
export function generateRandomString(length: number) {