This commit is contained in:
parent
9c9e2ef8d9
commit
e37fbd129a
|
|
@ -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]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue