修改home
This commit is contained in:
23
miniprogram/env.ts
Normal file
23
miniprogram/env.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
// 环境类型定义
|
||||
type EnvVersion = 'develop' | 'trial' | 'release';
|
||||
|
||||
// 配置类型定义
|
||||
interface EnvConfig {
|
||||
apiBaseUrl: string;
|
||||
}
|
||||
|
||||
// 获取当前环境
|
||||
const accountInfo = wx.getAccountInfoSync();
|
||||
const env = accountInfo.miniProgram.envVersion as EnvVersion;
|
||||
|
||||
// 环境配置映射
|
||||
const config: Record<EnvVersion, EnvConfig> = {
|
||||
develop: { apiBaseUrl: 'http://localhost:9096' },
|
||||
trial: { apiBaseUrl: 'https://test-api.example.com' },
|
||||
release: { apiBaseUrl: 'https://api.example.com' }
|
||||
};
|
||||
|
||||
// 处理未知环境(兜底方案)
|
||||
const envConfig = config[env] || config.develop;
|
||||
|
||||
export default envConfig;
|
||||
Reference in New Issue
Block a user