This commit is contained in:
hailin 2025-05-20 22:34:12 +08:00
parent 9c9e2ef8d9
commit e37fbd129a
1 changed files with 4 additions and 4 deletions

View File

@ -10,12 +10,12 @@
let _env: Record<string, string> | null = null
export function getRuntimeEnv(key: string): string | undefined {
if (_env) return _env[key]
// 强制每次从 window.RUNTIME_ENV 获取,而不依赖缓存
if (typeof window !== "undefined" && typeof window.RUNTIME_ENV !== "undefined") {
_env = window.RUNTIME_ENV
_env = window.RUNTIME_ENV // 更新 _env确保使用最新的环境变量
return _env[key]
}
// 如果没有 window.RUNTIME_ENV回退到 process.env
return process.env[key]
}
}