Explorar el Código

fix失效后跳转

Michael Wang hace 6 años
padre
commit
11496bb6cd
Se han modificado 2 ficheros con 5 adiciones y 4 borrados
  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) => {
   const loginPath = "/login/" + localStorage.getItem("domain");
-  if (to.path === loginPath) {
+  if (to.path.match(/^\/login\/.+$/)) {
     next();
   } else {
     if (!window.localStorage.getItem("token")) {
+      if (!localStorage.getItem("domain")) {
+        alert("地址出错,找不到机构!");
+      }
       next({ path: loginPath });
     } else {
       next();

+ 1 - 3
src/utils/axios.js

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