|
@@ -1,15 +1,8 @@
|
|
|
import axios from 'axios'
|
|
|
-import {
|
|
|
- // baseURL,
|
|
|
- contentType,
|
|
|
- debounce,
|
|
|
- requestTimeout,
|
|
|
- successCode,
|
|
|
- tokenName,
|
|
|
-} from '@/config'
|
|
|
import store from '@/store'
|
|
|
import qs from 'qs'
|
|
|
import router from '@/router'
|
|
|
+import { contentType, debounce, requestTimeout, successCode, tokenName, } from '@/config'
|
|
|
import { isArray } from '@/utils/validate'
|
|
|
import { message } from 'ant-design-vue'
|
|
|
|
|
@@ -17,10 +10,12 @@ import { message } from 'ant-design-vue'
|
|
|
|
|
|
let loadingInstance
|
|
|
|
|
|
+console.log(loadingInstance)
|
|
|
+console.log(loadingInstance.close())
|
|
|
+
|
|
|
var tag = true
|
|
|
|
|
|
/**
|
|
|
- * @author chuzhixin 1204505056@qq.com
|
|
|
* @description 处理code异常
|
|
|
* @param {*} code
|
|
|
* @param {*} msg
|
|
@@ -33,14 +28,12 @@ const handleCode = (code, msg) => {
|
|
|
message.error('登录状态已过期,请重新登陆!')
|
|
|
tag = false
|
|
|
}
|
|
|
- store.dispatch('user/resetAll').catch(() => {})
|
|
|
- store.dispatch('user/logout').catch(() => {})
|
|
|
+ store.dispatch('user/resetAll').catch(() => { })
|
|
|
+ store.dispatch('user/logout').catch(() => { })
|
|
|
router.replace({ path: "/login" });
|
|
|
-
|
|
|
-
|
|
|
break
|
|
|
case '403':
|
|
|
- router.push({ path: '/401' }).catch(() => {})
|
|
|
+ router.push({ path: '/401' }).catch(() => { })
|
|
|
break
|
|
|
default:
|
|
|
message.error(msg || `后端接口${code}异常`)
|
|
@@ -49,11 +42,10 @@ const handleCode = (code, msg) => {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @author chuzhixin 1204505056@qq.com
|
|
|
* @description axios初始化
|
|
|
*/
|
|
|
const baseURL = window.PLATFROM_CONFIG.baseUrl
|
|
|
- // console.log(baseURL)
|
|
|
+// console.log(baseURL)
|
|
|
const instance = axios.create({
|
|
|
baseURL,
|
|
|
timeout: requestTimeout,
|
|
@@ -63,7 +55,6 @@ const instance = axios.create({
|
|
|
})
|
|
|
|
|
|
/**
|
|
|
- * @author chuzhixin 1204505056@qq.com
|
|
|
* @description axios请求拦截器
|
|
|
*/
|
|
|
instance.interceptors.request.use(
|
|
@@ -87,7 +78,6 @@ instance.interceptors.request.use(
|
|
|
)
|
|
|
|
|
|
/**
|
|
|
- * @author chuzhixin 1204505056@qq.com
|
|
|
* @description axios响应拦截器
|
|
|
*/
|
|
|
instance.interceptors.response.use(
|
|
@@ -97,7 +87,7 @@ instance.interceptors.response.use(
|
|
|
const { code, msg } = data
|
|
|
// 操作正常Code数组
|
|
|
const codeVerificationArray = isArray(successCode) ? [...successCode] : [...[successCode]]
|
|
|
- // 是否操作正常
|
|
|
+ // 是否操作正常
|
|
|
if (codeVerificationArray.includes(parseInt(code))) {
|
|
|
return data
|
|
|
} else {
|