请问体验版环境跟线上环境的url如何做到自动切换?

小程序 文章 2021-03-05 14:21 437 0 全屏看文

AI助手支持GPT4.0

请问体验版环境跟线上环境的url如何做到自动切换?How can the url of the trial version environment and the online environment switch automatically?

请问体验版环境跟线上环境的url如何做到自动切换?

小程序请求后台的url被我写在app.js中,但体验版我们是指向测试环境的地址“http://xxtest.com”,到了要上线了只能手动将地址改成线上环境后再提交一版体验版去审核,然后又得手动把地址且回去,请问有没有什么办法可以做到线上环境与体验版环境使用不同的配置项呢

The URL of the small program request background is written by me in the app.js In the experience version, we point to the address of the test environment“ http://xxtest.com ”When it's time to go online, you can only manually change the address to the online environment, and then submit a version of the experience version for review. Then you have to manually change the address and go back. Is there any way to use a different configuration between the online environment and the experience version What about items

回答:

Brother斌🎈:

console.log('版本:', __wxConfig.envVersion);

版本: ‘develop’, //开发版

版本: ‘trial’, //体验版

版本: ‘release’, //正式版

看到其他问题有这样的回复,不过我没试过

太初:

我是有个配置文件,每次用 // 注释来切换

诗念不断:我也一样啊,天涯沦落人啊,如果能自动切换就好了,不然每次上线都怕自己马虎搞错了
🇭  🇬 :

测试环境的版本用账号A上传,并设置为体验版用于测试

生产环境的版本用账号B上传,不需要设置为体验版也可以用来发布审核

没有多个账号的话可以尝试用脚本来上传

https://developers.weixin.qq.com/miniprogram/dev/devtools/ci.html

指定不同 robot(ci 机器人),属于不同的账号


诗念不断:感谢,我了解了解

-EOF-

AI助手支持GPT4.0