瀏覽代碼

有token的时候 路由为登录,也像首页跳转

黄琪勇 7 月之前
父節點
當前提交
9a1dca3069
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      src/router/index.ts

+ 7 - 0
src/router/index.ts

@@ -56,6 +56,13 @@ router.beforeEach((to, from, next) => {
             })
       }
    } else {
+      // 如果有token,并且是登录页 直接返回首页
+      if (hasToken && to.path === "/login") {
+         next({
+            path: "/"
+         })
+         return
+      }
       if (authWhiteList.includes(to.path) || isRegWhite(regWhiteList, to.path)) {
          next()
       } else {