微信小程序发布试用版本
This commit is contained in:
@@ -27,7 +27,9 @@ function resolveApiEnv() {
|
||||
if (fileEnv) {
|
||||
const mapped = ENV_ALIAS[fileEnv.toLowerCase()]
|
||||
if (mapped) {
|
||||
// #ifdef APP-PLUS || H5 || MP-ALIPAY
|
||||
console.log('[API Config] 使用 env.js 配置:', fileEnv, '=>', mapped)
|
||||
// #endif
|
||||
return mapped
|
||||
}
|
||||
}
|
||||
@@ -39,7 +41,9 @@ function resolveApiEnv() {
|
||||
: ''
|
||||
const aliasKey = runtimeEnv ? runtimeEnv.toLowerCase() : ''
|
||||
const env = ENV_ALIAS[aliasKey] || 'prod'
|
||||
// #ifdef APP-PLUS || H5 || MP-ALIPAY
|
||||
console.log('[API Config] 使用环境变量:', runtimeEnv, '=>', env)
|
||||
// #endif
|
||||
return env
|
||||
}
|
||||
|
||||
@@ -49,8 +53,10 @@ const API_ENV = resolveApiEnv()
|
||||
export const API_BASE_URL = normalizeBaseUrl(API_TARGETS[API_ENV] || API_TARGETS.prod)
|
||||
|
||||
// 输出当前配置信息(便于调试)
|
||||
// #ifdef APP-PLUS || H5 || MP-ALIPAY
|
||||
console.log('[API Config] 当前环境:', API_ENV)
|
||||
console.log('[API Config] API_BASE_URL:', API_BASE_URL)
|
||||
// #endif
|
||||
|
||||
// 当前 API 环境(local / prod)
|
||||
export function getApiEnv() {
|
||||
@@ -66,14 +72,18 @@ export function getApiUrl(path = '') {
|
||||
// H5环境下,local / prod 都返回完整URL,确保 prod 时直接请求远程服务器
|
||||
const fullPath = apiPath.startsWith('/') ? apiPath.slice(1) : apiPath
|
||||
const fullUrl = `${API_BASE_URL}${fullPath}`
|
||||
// #ifdef APP-PLUS || H5 || MP-ALIPAY
|
||||
console.log(`[API Config] H5环境(${API_ENV})直接使用完整URL:`, fullUrl)
|
||||
// #endif
|
||||
return fullUrl
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
// 其他环境使用完整URL
|
||||
const fullPath = apiPath.startsWith('/') ? apiPath.slice(1) : apiPath
|
||||
const fullUrl = `${API_BASE_URL}${fullPath}`
|
||||
// #ifdef APP-PLUS || H5 || MP-ALIPAY
|
||||
console.log('[API Config] 非H5环境使用完整URL:', fullUrl)
|
||||
// #endif
|
||||
return fullUrl
|
||||
// #endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user