ソースを参照

fix: 当用户未登录时重定向到首页

Jinyao 5 年 前
コミット
f07228f205
1 ファイル変更3 行追加3 行削除
  1. 3 3
      src/router/index.ts

+ 3 - 3
src/router/index.ts

@@ -74,10 +74,10 @@ const router = createRouter({
 router.beforeEach((to, from, next) => {
   if (to.matched.some((record) => record.meta.requiresAuth)) {
     // this route requires auth, check if logged in
-    // if not, redirect to login page.
+    // if not, redirect to home page.
     if (!isUserLoggedIn()) {
       next({
-        name: LOGIN,
+        name: HOME,
         query: { redirect: to.fullPath },
       });
     } else {
@@ -89,7 +89,7 @@ router.beforeEach((to, from, next) => {
 });
 
 router.beforeEach((to, from, next) => {
-  if (to.name !== LOGIN || !isUserLoggedIn()) {
+  if (to.name !== HOME || !isUserLoggedIn()) {
     next();
   }
 });