/** * 环境配置文件 * * 开发环境(微信开发者工具)使用本地后端地址; * 生产环境使用线上域名。 */ 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 = { API_BASE_URL: isDev ? 'http://localhost:8085/api/v1' : 'https://api.danyang-match.example.com/api/v1', IS_DEV: isDev, };