feat: 开放服务器切换并修复扫码方式列表
This commit is contained in:
+9
-18
@@ -21,18 +21,15 @@ try{
|
||||
|
||||
// 初始化API URL
|
||||
function initApiUrl() {
|
||||
if (config.isDevelopment) {
|
||||
// 开发环境:从存储读取,如果没有则使用测试环境
|
||||
try {
|
||||
const savedApiUrl = uni.getStorageSync('ApiUrl');
|
||||
return savedApiUrl || config.devApiUrlOptions[0].value;
|
||||
} catch (e) {
|
||||
console.log('读取存储的 apiurl 失败', e);
|
||||
return config.devApiUrlOptions[0].value;
|
||||
}
|
||||
} else {
|
||||
// 生产环境:使用固定的生产URL
|
||||
return config.productionApiUrl;
|
||||
const fallbackUrl = config.isDevelopment
|
||||
? config.devApiUrlOptions[0].value
|
||||
: ((config.devApiUrlOptions.find(item => item.label === '正式环境') || {}).value || config.productionApiUrl);
|
||||
try {
|
||||
const savedApiUrl = uni.getStorageSync('ApiUrl');
|
||||
return savedApiUrl || fallbackUrl;
|
||||
} catch (e) {
|
||||
console.log('读取存储的 apiurl 失败', e);
|
||||
return fallbackUrl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,13 +102,7 @@ const store = new Vuex.Store({
|
||||
state.vuex_notificationAudio = audio;
|
||||
},
|
||||
SET_API_URL(state, url) {
|
||||
// 生产环境不允许修改URL
|
||||
if (!config.isDevelopment) {
|
||||
console.warn('生产环境不允许修改API URL');
|
||||
return;
|
||||
}
|
||||
state.apiurl = url
|
||||
// 同时保存到本地存储
|
||||
uni.setStorageSync('ApiUrl', url)
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user