From 036e934a24d0409b32c5fbb5f18ef061de08b192 Mon Sep 17 00:00:00 2001 From: lipeng Date: Wed, 21 Jun 2023 18:00:25 +0800 Subject: [PATCH] modify --- src/router/index.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/router/index.js b/src/router/index.js index c0dd187..c26ebc1 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -6,6 +6,7 @@ import store from "../store"; //写入初始必须有的路由 //或者隐藏式路由,不会表现在菜单上,但是需要存在的路由 +<<<<<<< Updated upstream const routes = [{ path: "/login", name: "login", @@ -39,6 +40,31 @@ const routes = [{ component: () => import ("../page/404.vue"), }, +======= +const routes = [ + { + path: "/login", + name: "login", + show: true, + component: () => import("../page/login/index.vue"), + }, + { + path: "/register", + name: "register", + show: true, + component: () => import("../page/register/index.vue"), + }, + { + path: "/", + name: "index", + component: () => import("../page/welcom.vue"), + }, + { + path: "/404", + show: true, + component: () => import("../page/404.vue"), + }, +>>>>>>> Stashed changes ]; //重新创建router @@ -63,6 +89,16 @@ function inWhiteList(toPath) { } router.beforeEach((to, from, next) => { +<<<<<<< Updated upstream +======= + const userInfo = store.state.userInfo; + //已登录不可跳转登陆页 || to.path == "/" 去除首页跳转判断 + if (userInfo && to.path == "/login") { + return next({ + path: "/", + }); + } +>>>>>>> Stashed changes const userInfo = store.state.userInfo -- 2.26.0