/** * 环境配置 */ declare const wx: WechatMiniprogram.Wx; function isDev(): boolean { try { const accountInfo = typeof wx.getAccountInfoSync === 'function' ? wx.getAccountInfoSync() : null; if (accountInfo?.miniProgram?.envVersion === 'develop') { return true; } const info = (wx.getDeviceInfo ? wx.getDeviceInfo() : wx.getSystemInfoSync()) as any; return info.platform === 'devtools'; } catch { return false; } } // 生产环境后端地址(线上正式域名)。 // 部署前必须替换为真实域名,并到小程序后台「开发管理 → 开发设置 → 服务器域名」配置 request 合法域名。 // 如需在构建期注入(CI/打包脚本),可在打包前以全局 __DY_PROD_API_BASE__ 覆盖本默认值。 declare const __DY_PROD_API_BASE__: string | undefined; const PROD_API_BASE_URL: string = (typeof __DY_PROD_API_BASE__ !== 'undefined' ? __DY_PROD_API_BASE__ : undefined) || 'https://api.danyang-match.example.com/api/v1'; // TODO(部署): 替换为真实生产域名 export const API_BASE_URL: string = isDev() ? 'http://127.0.0.1:8085/api/v1' : PROD_API_BASE_URL; export const IS_DEV: boolean = isDev();