|
|
@@ -7,10 +7,13 @@ const service = axios.create({
|
|
|
baseUrl: '/'
|
|
|
})
|
|
|
|
|
|
+let reqCount = 0 // 请求计数器
|
|
|
+
|
|
|
const isServer = typeof window === 'undefined'
|
|
|
service.interceptors.request.use(config => {
|
|
|
// is server render, use ${baseUrl} directly rather than ${proxyUrl}
|
|
|
config.url = config.url || '/'
|
|
|
+ reqCount++
|
|
|
if (isServer) {
|
|
|
if (config.url.indexOf('/inquiry') === 0) {
|
|
|
config.url = process.env.commonUrl + config.url
|
|
|
@@ -44,12 +47,12 @@ service.interceptors.response.use(response => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (!isServer) {
|
|
|
+ if (!isServer && --reqCount === 0) {
|
|
|
document.getElementById('loading').setAttribute('class', 'loading')
|
|
|
}
|
|
|
return response
|
|
|
}, error => {
|
|
|
- if (!isServer) {
|
|
|
+ if (!isServer && --reqCount === 0) {
|
|
|
document.getElementById('loading').setAttribute('class', 'loading')
|
|
|
}
|
|
|
return Promise.reject(error)
|