|
@@ -13,8 +13,9 @@ const service = axios.create({
|
|
|
|
|
|
// request拦截器
|
|
|
service.interceptors.request.use(config => {
|
|
|
- if (store.getters.token) {
|
|
|
- config.headers['Authorization'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
|
|
+ let tocken =getToken()
|
|
|
+ if (tocken) {
|
|
|
+ config.headers['Authorization'] = tocken // 让每个请求携带自定义token 请根据实际情况自行修改
|
|
|
}
|
|
|
if(config.url.indexOf('/api-mall-admin')== -1){
|
|
|
if(config.url.indexOf('/api-admin')== -1 && config.url.indexOf('/api-auth')== -1){
|
|
@@ -60,17 +61,19 @@ service.interceptors.response.use(
|
|
|
|
|
|
// 401:未登录;
|
|
|
if (res.code === 401 || res.code === 403) {
|
|
|
+ console.log('401/403')
|
|
|
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;
|
|
|
- // // })
|
|
|
- location.replace(location.origin);
|
|
|
+ // store.dispatch('FedLogOut').then(() => {
|
|
|
+ // location.reload()// 为了重新实例化vue-router对象 避免bug
|
|
|
+ // location.href = window.location.hostname;
|
|
|
+ // })
|
|
|
+
|
|
|
// })
|
|
|
}
|
|
|
return Promise.reject('error')
|