叶志浩 vor 4 Monaten
Ursprung
Commit
77bd49d072
2 geänderte Dateien mit 7 neuen und 3 gelöschten Zeilen
  1. 1 1
      common/config.js
  2. 6 2
      common/httpRequest.js

+ 1 - 1
common/config.js

@@ -6,7 +6,7 @@ const productionChatUrl = 'wss://www.bosszan.com/wss/chatSocket/'
 const testApiUrl = 'https://yizhizan.edccc.cn/sqx_fast'
 const testWssUrl = 'wss://yizhizan.edccc.cn/wss/websocket/'
 const testChatUrl = 'wss://yizhizan.edccc.cn/wss/chatSocket/'
-let isProduction = false // 判断是否是生产环境
+let isProduction = true // 判断是否是生产环境
 if (isProduction) {
 	//正式环境
 	const ROOTPATH = productionApiUrl;

+ 6 - 2
common/httpRequest.js

@@ -4,8 +4,6 @@ import queue from './queue'
 
 let domainReadyPromise = null
 
-ensureDomainReady()
-
 // 确保已经从后端拿到动态域名配置(只会真实请求一次)
 function ensureDomainReady() {
 	// 1)如果本地已经有 web_config,直接返回
@@ -25,6 +23,7 @@ function ensureDomainReady() {
 				type: '路由'
 			},
 			method: 'GET',
+			timeout: 8000,
 			success: (res) => {
 				if (res.data && res.data.code === 0 && res.data.data) {
 					const cfg = res.data.data
@@ -36,6 +35,11 @@ function ensureDomainReady() {
 			},
 			complete: () => {
 				// 无论成功失败,都结束,失败时后面会走 config.js 兜底
+				// 但如果本次没有成功拿到 web_config,需要允许后续请求再次触发拉取(避免首次安装/弱网导致永久不生效)
+				const latest = cache.get('web_config')
+				if (!latest || !latest.APIHOST) {
+					domainReadyPromise = null
+				}
 				resolve()
 			}
 		})