소스 검색

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

CzRger 1 년 전
부모
커밋
cea115feb3
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  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)