Explorar el Código

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

CzRger hace 1 año
padre
commit
cea115feb3
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  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)