// 环境类型定义 type EnvVersion = 'develop' | 'trial' | 'release'; // 配置类型定义 interface EnvConfig { apiBaseUrl: string; } // 获取当前环境 const accountInfo = wx.getAccountInfoSync(); const env = accountInfo.miniProgram.envVersion as EnvVersion; // 环境配置映射 const config: Record = { 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;