|
|
@@ -1,5 +1,5 @@
|
|
|
import axios from 'axios'
|
|
|
-import { getTokenInfo, removeTokenInfo } from './storage'
|
|
|
+import { getTokenInfo, hasToken, removeTokenInfo } from './storage'
|
|
|
import store from '@/store'
|
|
|
import { MessageFu } from './message'
|
|
|
import { domShowFu } from './domShow'
|
|
|
@@ -39,7 +39,6 @@ let axajInd = 0
|
|
|
// 请求拦截器
|
|
|
http.interceptors.request.use(
|
|
|
function (config: any) {
|
|
|
- // if (isMyAlert) alert(`开始发送接口:${JSON.stringify(config)}`)
|
|
|
// 发请求前打开加载提示
|
|
|
domShowFu('#AsyncSpinLoding', true)
|
|
|
|
|
|
@@ -68,8 +67,6 @@ let timeId = -1
|
|
|
// 响应拦截器
|
|
|
http.interceptors.response.use(
|
|
|
function (response) {
|
|
|
- // if (isMyAlert) alert(`发送请求成功:${JSON.stringify(response)}`)
|
|
|
-
|
|
|
// 请求回来的关闭加载提示
|
|
|
axajInd--
|
|
|
if (axajInd === 0) {
|
|
|
@@ -86,17 +83,15 @@ http.interceptors.response.use(
|
|
|
// MessageFu.success(response.data.msg);
|
|
|
} else if (![3014, 3101, 3510].includes(response.data.code)) {
|
|
|
if (response.data.code === -1 && response.data.msg === '对象不存在') {
|
|
|
- history.replace('/abnormal?k=5')
|
|
|
+ if (hasToken()) history.replace('/abnormal?k=5')
|
|
|
} else MessageFu.warning(response.data.msg)
|
|
|
}
|
|
|
|
|
|
- if (response.data.code === 3510) history.replace('/abnormal')
|
|
|
+ if (response.data.code === 3510) if (hasToken()) history.replace('/abnormal')
|
|
|
|
|
|
return response.data
|
|
|
},
|
|
|
async function (err) {
|
|
|
- // if (isMyAlert) alert(`发送请求失败:${err}`)
|
|
|
-
|
|
|
clearTimeout(timeId)
|
|
|
timeId = window.setTimeout(() => {
|
|
|
axajInd = 0
|
|
|
@@ -106,7 +101,7 @@ http.interceptors.response.use(
|
|
|
if (store.getState().A0Layout.closeUpFile.state) MessageFu.warning('取消上传!')
|
|
|
else {
|
|
|
MessageFu.error('网络繁忙,请稍后重试!')
|
|
|
- history.replace('/abnormal?k=2')
|
|
|
+ if (hasToken()) history.replace('/abnormal?k=2')
|
|
|
}
|
|
|
} else {
|
|
|
if (
|
|
|
@@ -120,10 +115,10 @@ http.interceptors.response.use(
|
|
|
if (err.response.data.code === 5003) {
|
|
|
removeTokenInfo()
|
|
|
loginOutFu()
|
|
|
- } else history.replace('/abnormal?k=1')
|
|
|
+ } else if (hasToken()) history.replace('/abnormal?k=1')
|
|
|
} else {
|
|
|
MessageFu.error('响应错误,请联系管理员!')
|
|
|
- history.replace('/abnormal?k=1')
|
|
|
+ if (hasToken()) history.replace('/abnormal?k=1')
|
|
|
}
|
|
|
}
|
|
|
}, 100)
|