psycho 6 سال پیش
والد
کامیت
20ae051025
2فایلهای تغییر یافته به همراه14 افزوده شده و 5 حذف شده
  1. 13 4
      TEAMModelOS/ClientApp/utils/http.js
  2. 1 1
      TEAMModelOS/ClientApp/view/index.vue

+ 13 - 4
TEAMModelOS/ClientApp/utils/http.js

@@ -1,4 +1,6 @@
 import axios from 'axios';
+import Vue from 'vue'
+import router from '@/router/index'
 axios.defaults.timeout = 5000;
 axios.defaults.baseURL ='';
 
@@ -31,16 +33,23 @@ axios.interceptors.request.use(
 //http response 拦截器
 axios.interceptors.response.use(
   response => {
-    if(response.data.errCode ==2){
+    if (response.data.errCode == 2) {
       router.push({
-        path:"/login",
-        querry:{redirect:router.currentRoute.fullPath}//从哪个页面跳转
+        path: "/login",
+        querry: { redirect: router.currentRoute.fullPath }//从哪个页面跳转
       })
     }
     return response;
   },
   error => {
-    return Promise.reject(error)
+    if (401 === error.response.status) {
+      localStorage.clear();
+      console.log(window.location);
+      window.location.href = window.location.origin;
+      alert("登录状态已过期!请重新登录!");
+    } else {
+      return Promise.reject(error);
+    }
   }
 )
 

+ 1 - 1
TEAMModelOS/ClientApp/view/index.vue

@@ -126,7 +126,7 @@
             that.getAuthSchool();
           }
           }).catch(res => {
-            that.$Message.warning("当前未登录");
+            //that.$Message.warning("当前未登录");
             that.$Spin.hide();
           })
       },