wenhongquan 3 ani în urmă
părinte
comite
f98bdc07f0
2 a modificat fișierele cu 14 adăugiri și 5 ștergeri
  1. 11 4
      src/router/index.ts
  2. 3 1
      src/utils/request.ts

+ 11 - 4
src/router/index.ts

@@ -77,6 +77,7 @@ router.beforeEach(async (to, from) => {
   // }
   var route = router.currentRoute.value;
   var islogin = false;
+  // debugger
   //判断url是否含有ticket
   if (route.query.ticket != undefined && route.query.ticket != null) {
     //存在ticket 根据ticket获取token 并保存清除ticket
@@ -95,11 +96,17 @@ router.beforeEach(async (to, from) => {
     let userinfojson = window.localStorage.getItem('userdata');
     if (userinfojson != undefined || userinfojson != null) {
       islogin = true;
+    } else { 
+       setTimeout(() => {
+          window.location.href = LOGIN_URL;
+       }, 1000);
+      
     }
-    if (!islogin) {
-      // debugger
-      window.location.href = LOGIN_URL;
-    }
+    // if (!islogin) {
+    //   // debuggerlocation.reload();
+    //   // location.reload();
+      // window.location.href = LOGIN_URL;
+    // }
   }
 
   // main.clearReqToken();

+ 3 - 1
src/utils/request.ts

@@ -37,7 +37,8 @@ axios.interceptors.response.use(
           // message: `401. 没有权限访问该接口: ${res.config.url}`,
           message: `401. 没有权限访问该接口`,
         });
-         if (res.data.data.indexOf('Jwt expired') != -1) {
+        if (res.data.data.indexOf('Jwt expired') != -1) {
+           debugger
            window.localStorage.removeItem('userdata');
            window.location.href = LOGIN_URL;
          }
@@ -70,6 +71,7 @@ axios.interceptors.response.use(
 
     if (res.status >= 500) {
       if (res.data?.message == 'invalid ticket') {
+        debugger
         window.localStorage.removeItem('userdata');
         window.location.href = LOGIN_URL;
       }