feat(mini-program): 添加 env.js 环境配置诊断日志

- 在 getConfig() 函数中添加条件日志输出
- 输出原始环境变量、解析后配置、来源标识
- 仅在 DEBUG=true 时打印
This commit is contained in:
2026-03-18 22:50:16 +08:00
parent 6a423da5f0
commit bf41bded8b
+13
View File
@@ -39,6 +39,19 @@ const getConfig = () => {
const debug = import.meta.env.VITE_DEBUG !== undefined
? import.meta.env.VITE_DEBUG === 'true'
: base.DEBUG
// 添加诊断日志
if (debug) {
console.log('[ENV] 环境配置:', {
rawEnv: import.meta.env.VITE_APP_ENV,
normalizedEnv: currentEnv,
API_BASE_URL: apiBaseUrl,
WS_URL: wsUrl,
DEBUG: debug,
isFromEnvFile: import.meta.env.VITE_API_BASE_URL ? 'yes' : 'fallback-to-config'
})
}
return {
API_BASE_URL: apiBaseUrl,
WS_URL: wsUrl,