Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
梁建民
/
scm_app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c255ec1f
authored
May 28, 2026
by
liangjianmin
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix(api): 自动切换小程序环境为生产模式
在微信小程序正式版中,自动将环境变量切换为生产模式。 增加了对小程序版本信息的获取和错误处理。
parent
9f6d5b59
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletions
util/api.js
util/api.js
View file @
c255ec1f
// 环境配置:'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
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment