Files

33 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

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