/** * 环境配置文件 * * 开发环境(微信开发者工具)使用本地后端地址; * 生产环境使用线上域名。 */ const isDev = (function() { try { const accountInfo = typeof wx.getAccountInfoSync === 'function' ? wx.getAccountInfoSync() : null; if (accountInfo && accountInfo.miniProgram && accountInfo.miniProgram.envVersion === 'develop') { return true; } // 兼容旧基础库与部分自动化运行环境。 const info = wx.getDeviceInfo ? wx.getDeviceInfo() : wx.getSystemInfoSync(); return info.platform === 'devtools'; } catch (e) { return false; } })(); module.exports = { // 生产环境后端地址(线上正式域名)。 // 部署前必须替换为真实域名,并到小程序后台「开发管理 → 开发设置 → 服务器域名」配置 request 合法域名。 // 注意:本文件不得再出现散落的硬编码地址,统一改这里即可。 API_BASE_URL: isDev ? 'http://localhost:8085/api/v1' : 'https://api.danyang-match.example.com/api/v1', // TODO(部署): 替换为真实生产域名 IS_DEV: isDev, };