|
@@ -4,6 +4,7 @@ import store from '../store'
|
|
|
import { getToken } from '@/utils/auth'
|
|
|
import cleanDeep from 'clean-deep'
|
|
|
import qs from 'qs'
|
|
|
+import router from '../router'
|
|
|
|
|
|
// 创建axios实例
|
|
|
const service = axios.create({
|
|
@@ -45,7 +46,7 @@ service.interceptors.request.use(config => {
|
|
|
|
|
|
// respone拦截器
|
|
|
service.interceptors.response.use(
|
|
|
- response => {
|
|
|
+async response => {
|
|
|
/**
|
|
|
* code为非200是抛错 可结合自己业务进行修改
|
|
|
*/
|
|
@@ -60,17 +61,17 @@ service.interceptors.response.use(
|
|
|
|
|
|
// 401:未登录;
|
|
|
if (res.code === 401 || res.code === 403) {
|
|
|
- location.reload()
|
|
|
+ // 清理缓存 跳到登录页面
|
|
|
+ await store.dispatch('FedLogOut')
|
|
|
+ location.reload()
|
|
|
+
|
|
|
// location = window.location.origin;
|
|
|
// MessageBox.confirm('登录过期请重新登录', '确定登出', {
|
|
|
// confirmButtonText: '重新登录',
|
|
|
// cancelButtonText: '取消',
|
|
|
// type: 'warning'
|
|
|
// }).then(() => {
|
|
|
- // store.dispatch('FedLogOut').then(() => {
|
|
|
- // location.reload()// 为了重新实例化vue-router对象 避免bug
|
|
|
- // location.href = window.location.hostname;
|
|
|
- // })
|
|
|
+
|
|
|
|
|
|
// })
|
|
|
}
|