zhangjie 2 years ago
parent
commit
35a33dd7b6
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/router/index.js

+ 11 - 1
src/router/index.js

@@ -261,12 +261,18 @@ const routes = [
       import(
         /* webpackChunkName: "download" */ "../features/download/Download.vue"
       ),
+    meta: {
+      noAuth: true,
+    },
   },
   {
     path: "/login",
     name: "Login",
     component: () =>
       import(/* webpackChunkName: "Login" */ "../features/Login/Login.vue"),
+    meta: {
+      noAuth: true,
+    },
   },
   {
     path: "*",
@@ -289,8 +295,12 @@ router.beforeEach((to, from, next) => {
   if (to.path) {
     window._hmt.push(["_trackPageview", to.fullPath]);
   }
+  if (to.meta.noAuth) {
+    next();
+    return;
+  }
   const token = getToken();
-  if (isNil(token) && to.path.includes("/login") === false) {
+  if (isNil(token)) {
     router.push("/login?redirectTo=" + encodeURI(to.fullPath));
     next(false);
   } else {