zhaoke 2 жил өмнө
parent
commit
a501ed5eae
1 өөрчлөгдсөн 21 нэмэгдсэн , 16 устгасан
  1. 21 16
      src/utils/request.js

+ 21 - 16
src/utils/request.js

@@ -130,7 +130,7 @@ service.interceptors.response.use(
           type: 'error',
           duration: 5 * 1000,
           onClose: () => {
-            store.dispatch('tagsView/delAllViews').then(() => {})
+            store.dispatch('tagsView/delAllViews').then(() => { })
             store.dispatch('user/resetToken').then(() => {
               location.reload()
             })
@@ -172,32 +172,37 @@ service.interceptors.response.use(
   },
   error => {
     // console.log('err', error) // for debug
-    const des = `${error}`.split(' ').includes('500')
-    if (des) {
-      // console.log()
-      // return;
+    const des500 = `${error}`.split(' ').includes('500')
+    const des401 = `${error}`.split(' ').includes('401')
+    if (des401) {
+      Message({
+        message: '当前帐号已在其他环境登录,如非本人登录,请检查密码是否泄漏!',
+        type: 'error',
+        duration: 5 * 1000,
+        onClose: () => {
+          store.dispatch('app/toggleDialog', false)
+          store.dispatch('tagsView/delAllViews').then(() => { })
+          store.dispatch('user/resetToken').then(() => {
+            location.reload()
+          })
+        }
+      })
+    }
+    else if (des500) {
       Message({
         message: '身份令牌过期或失效,即将重新登录',
         type: 'error',
         duration: 5 * 1000,
         onClose: () => {
           store.dispatch('app/toggleDialog', false)
-          store.dispatch('tagsView/delAllViews').then(() => {})
+          store.dispatch('tagsView/delAllViews').then(() => { })
           store.dispatch('user/resetToken').then(() => {
             location.reload()
           })
         }
       })
-      // MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', {
-      //   confirmButtonText: 'Re-Login',
-      //   cancelButtonText: 'Cancel',
-      //   type: 'warning'
-      // }).then(() => {
-      //   store.dispatch('user/resetToken').then(() => {
-      //     location.reload()
-      //   })
-      // })
-    } else {
+    }
+    else {
       Message({
         message: error.message,
         type: 'error',