mo 2 years ago
parent
commit
60d4d41384
1 changed files with 14 additions and 11 deletions
  1. 14 11
      src/utils/request.js

+ 14 - 11
src/utils/request.js

@@ -29,7 +29,9 @@ service.interceptors.response.use(
   /**
   * code为非200是抛错 可结合自己业务进行修改
   */
+
     const res = response.data
+    console.log(res,'res')
     if (res.code !== 200) {
       Message({
         message: res.message,
@@ -39,17 +41,18 @@ service.interceptors.response.use(
 
       // 401:未登录;
       if (res.code === 401 || res.code === 403) {
-        MessageBox.confirm('登录过期请重新登录', '确定登出', {
-          confirmButtonText: '重新登录',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          // store.dispatch('FedLogOut').then(() => {
-          //   // location.reload()// 为了重新实例化vue-router对象 避免bug
-          //   location.href = window.location.hostname;
-          // })
-          location.href = window.location.hostname;
-        })
+        location = window.location.hostname;
+        // MessageBox.confirm('登录过期请重新登录', '确定登出', {
+        //   confirmButtonText: '重新登录',
+        //   cancelButtonText: '取消',
+        //   type: 'warning'
+        // }).then(() => {
+        //   // store.dispatch('FedLogOut').then(() => {
+        //   //   // location.reload()// 为了重新实例化vue-router对象 避免bug
+        //   //   location.href = window.location.hostname;
+        //   // })
+        //   location.href = window.location.hostname;
+        // })
       }
       return Promise.reject('error')
     } else {