Commit c255ec1f by liangjianmin

fix(api): 自动切换小程序环境为生产模式

在微信小程序正式版中,自动将环境变量切换为生产模式。
增加了对小程序版本信息的获取和错误处理。
parent 9f6d5b59
Showing with 15 additions and 1 deletions
// 环境配置:'production' 正式环境 | 'development' 测试环境
const ENV = 'development';
var ENV = 'development';
// 微信小程序线上(正式版)自动切换为 production
// #ifdef MP-WEIXIN
try {
var accountInfo = uni.getAccountInfoSync();
var envVersion = accountInfo.miniProgram.envVersion;
// envVersion: develop(开发版) | trial(体验版) | release(正式版)
if (envVersion === 'release') {
ENV = 'production';
}
} catch (e) {
console.warn('[环境] 获取小程序版本信息失败', e);
}
// #endif
// 环境配置映射
var ENV_CONFIG = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment