diff --git a/src/router/index.js b/src/router/index.js index c0dd1870579f14058e9b7a2c0982722d24f43ee7..c26ebc1bccde1db25476671ca39c769201af8edf 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