dedsudiyu дней назад: 2
Родитель
Сommit
17f47d2261
1 измененных файлов с 34 добавлено и 36 удалено
  1. 34 36
      src/utils/request.js

+ 34 - 36
src/utils/request.js

@@ -124,24 +124,24 @@ serviceAxios.interceptors.response.use(res => {
     }
   },
   (error) => {
-    // if (error.response.data.code == 5002) {
-    //   removeToken()
-    //   MessageBox.confirm('登录状态已过期,请重新登录', '系统提示', {
-    //       confirmButtonText: '确定',
-    //       showCancelButton: false,
-    //       closeOnClickModal: false,
-    //       cancelButtonText: '取消',
-    //       type: 'warning'
-    //     }
-    //   ).then(() => {
-    //     if (localStorage.getItem('entranceJumpType') == 'PC') {
-    //       window.location.href = process.env.VUE_APP_OUT_URL
-    //     } else {
-    //       window.location.href = '#/'
-    //     }
-    //   }).catch(() => {
-    //   })
-    // }
+    if (error.response.data.code == 5002) {
+      removeToken()
+      MessageBox.confirm('登录状态已过期,请重新登录', '系统提示', {
+          confirmButtonText: '确定',
+          showCancelButton: false,
+          closeOnClickModal: false,
+          cancelButtonText: '取消',
+          type: 'warning'
+        }
+      ).then(() => {
+        if (localStorage.getItem('entranceJumpType') == 'PC') {
+          window.location.href = process.env.VUE_APP_OUT_URL
+        } else {
+          window.location.href = '#/'
+        }
+      }).catch(() => {
+      })
+    }
     // 弹层相关
     loadingCount--
     if (loadingCount === 0) {
@@ -156,24 +156,22 @@ serviceAxios.interceptors.response.use(res => {
     }
     else if (message.includes('Request failed with status code')) {
       if (message.substr(message.length - 3) == 401) {
-        if (getToken()) {
-          removeToken()
-          MessageBox.confirm('登录状态已过期,请重新登录', '系统提示', {
-              confirmButtonText: '确定',
-              showCancelButton: false,
-              closeOnClickModal: false,
-              cancelButtonText: '取消',
-              type: 'warning'
-            }
-          ).then(() => {
-            if (localStorage.getItem('entranceJumpType') == 'PC') {
-              window.location.href = process.env.VUE_APP_OUT_URL
-            } else {
-              window.location.href = '#/'
-            }
-          }).catch(() => {
-          })
-        }
+        removeToken()
+        MessageBox.confirm('登录状态已过期,请重新登录', '系统提示', {
+            confirmButtonText: '确定',
+            showCancelButton: false,
+            closeOnClickModal: false,
+            cancelButtonText: '取消',
+            type: 'warning'
+          }
+        ).then(() => {
+          if (localStorage.getItem('entranceJumpType') == 'PC') {
+            window.location.href = process.env.VUE_APP_OUT_URL
+          } else {
+            window.location.href = '#/'
+          }
+        }).catch(() => {
+        })
       } else {
         messageData = Message({
           message: message,