feat(mini-program): 添加 env.js 环境配置诊断日志
- 在 getConfig() 函数中添加条件日志输出 - 输出原始环境变量、解析后配置、来源标识 - 仅在 DEBUG=true 时打印
This commit is contained in:
@@ -39,6 +39,19 @@ const getConfig = () => {
|
|||||||
const debug = import.meta.env.VITE_DEBUG !== undefined
|
const debug = import.meta.env.VITE_DEBUG !== undefined
|
||||||
? import.meta.env.VITE_DEBUG === 'true'
|
? import.meta.env.VITE_DEBUG === 'true'
|
||||||
: base.DEBUG
|
: 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 {
|
return {
|
||||||
API_BASE_URL: apiBaseUrl,
|
API_BASE_URL: apiBaseUrl,
|
||||||
WS_URL: wsUrl,
|
WS_URL: wsUrl,
|
||||||
|
|||||||
Reference in New Issue
Block a user