@@ -24,27 +24,34 @@ service.interceptors.request.use(config => {
24
24
25
25
// respone拦截器
26
26
service . interceptors . response . use (
27
- response => response
27
+ response => response ,
28
28
/**
29
29
* 下面的注释为通过response自定义code来标示请求状态,当code返回如下情况为权限有问题,登出并返回到登录页
30
30
* 如通过xmlhttprequest 状态码标识 逻辑可写在下面error中
31
31
*/
32
- // const code = response.data.code;
33
- // // 50014:Token 过期了 50012:其他客户端登录了 50008:非法的token
34
- // if (code === 50008 || code === 50014 || code === 50012) {
35
- // Message({
36
- // message: res.message,
37
- // type: 'error',
38
- // duration: 5 * 1000
39
- // });
40
- // // 登出
41
- // store.dispatch('FedLogOut').then(() => {
42
- // router.push({ path: '/login' })
43
- // });
44
- // } else {
45
- // return response
46
- // }
47
- ,
32
+ // const res = response.data;
33
+ // if (res.code !== 20000) {
34
+ // Message({
35
+ // message: res.message,
36
+ // type: 'error',
37
+ // duration: 5 * 1000
38
+ // });
39
+ // // 50008:非法的token; 50012:其他客户端登录了; 50014:Token 过期了;
40
+ // if (res.code === 50008 || res.code === 50012 || res.code === 50014) {
41
+ // MessageBox.confirm('你已被登出,可以取消继续留在该页面,或者重新登录', '确定登出', {
42
+ // confirmButtonText: '重新登录',
43
+ // cancelButtonText: '取消',
44
+ // type: 'warning'
45
+ // }).then(() => {
46
+ // store.dispatch('FedLogOut').then(() => {
47
+ // location.reload();// 为了重新实例化vue-router对象 避免bug
48
+ // });
49
+ // })
50
+ // }
51
+ // return Promise.reject(error);
52
+ // } else {
53
+ // return response.data;
54
+ // }
48
55
error => {
49
56
console . log ( 'err' + error ) ; // for debug
50
57
Message ( {
0 commit comments