|
|
@@ -9,12 +9,11 @@ const service = axios.create({
|
|
|
|
|
|
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 (process.server) {
|
|
|
if (config.url.indexOf('/inquiry') === 0) {
|
|
|
config.url = process.env.commonUrl + config.url
|
|
|
} else if (config.url.indexOf('/productsuer') === 0) {
|
|
|
@@ -59,12 +58,12 @@ service.interceptors.response.use(response => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (--reqCount <= 0 && !isServer) {
|
|
|
+ if (--reqCount <= 0 && !process.server) {
|
|
|
document.getElementById('loading').setAttribute('class', 'loading')
|
|
|
}
|
|
|
return response
|
|
|
}, error => {
|
|
|
- if (--reqCount <= 0 && !isServer) {
|
|
|
+ if (--reqCount <= 0 && !process.server) {
|
|
|
document.getElementById('loading').setAttribute('class', 'loading')
|
|
|
}
|
|
|
return Promise.reject(error)
|