Files
Neo-ZQYY/apps/miniprogram - 副本/miniprogram/utils/config.ts

27 lines
658 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 环境配置
*
* 根据小程序运行环境自动切换 API 地址:
* - develop开发版→ 本机
* - trial体验版→ 测试环境
* - release正式版→ 正式环境
*/
function getApiBase(): string {
const accountInfo = wx.getAccountInfoSync()
const envVersion = accountInfo.miniProgram.envVersion
switch (envVersion) {
case "develop":
return "http://127.0.0.1:8000"
case "trial":
return "https://api.langlangzhuoqiu.cn"
case "release":
return "https://api.langlangzhuoqiu.cn"
default:
return "https://api.langlangzhuoqiu.cn"
}
}
export const API_BASE = getApiBase()