Browse Source

fix失效后跳转

Michael Wang 6 years ago
parent
commit
11496bb6cd
2 changed files with 5 additions and 4 deletions
  1. 4 1
      src/router.js
  2. 1 3
      src/utils/axios.js

+ 4 - 1
src/router.js

@@ -70,10 +70,13 @@ let router = new Router({
 
 
 router.beforeEach((to, from, next) => {
 router.beforeEach((to, from, next) => {
   const loginPath = "/login/" + localStorage.getItem("domain");
   const loginPath = "/login/" + localStorage.getItem("domain");
-  if (to.path === loginPath) {
+  if (to.path.match(/^\/login\/.+$/)) {
     next();
     next();
   } else {
   } else {
     if (!window.localStorage.getItem("token")) {
     if (!window.localStorage.getItem("token")) {
+      if (!localStorage.getItem("domain")) {
+        alert("地址出错,找不到机构!");
+      }
       next({ path: loginPath });
       next({ path: loginPath });
     } else {
     } else {
       next();
       next();

+ 1 - 3
src/utils/axios.js

@@ -76,9 +76,7 @@ qmInstance.interceptors.response.use(
     // 登录失效 跳转登录页面
     // 登录失效 跳转登录页面
     if (status == 403 || status == 401) {
     if (status == 403 || status == 401) {
       wk_token = null;
       wk_token = null;
-      router.push({
-        name: "Login"
-      });
+      router.push("/login/" + localStorage.getItem("domain"));
     }
     }
     return Promise.reject(error);
     return Promise.reject(error);
   }
   }