Procházet zdrojové kódy

已登录后,打开登录页自动跳转到首页

CzRger před 1 rokem
rodič
revize
cea115feb3
1 změnil soubory, kde provedl 5 přidání a 1 odebrání
  1. 5 1
      src/router/index.ts

+ 5 - 1
src/router/index.ts

@@ -33,7 +33,11 @@ const router = createRouter({
 
 router.beforeEach((to, from , next) => {
     if (to.path === "/login") {
-        next()
+        if (sessionStorage.getItem("sg_token")) {
+            location.replace('/')
+        } else {
+            next()
+        }
     } else {
         if (sessionStorage.getItem("sg_token")) {
             getInit(to, next)