|
|
@@ -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()
|
|
|
}
|
|
|
})
|