| | |
| | | } |
| | | |
| | | /** 路由白名单 */ |
| | | // const whiteList = ["/login"]; |
| | | const whiteList = []; |
| | | const whiteList = ["/login"]; |
| | | const noLoginList = ["/index", "/register", "/registersucess"]; |
| | | // const whiteList = []; |
| | | |
| | | const { VITE_HIDE_HOME } = import.meta.env; |
| | | |
| | |
| | | } |
| | | // 开启隐藏首页后在浏览器地址栏手动输入首页welcome路由则跳转到404页面 |
| | | if (VITE_HIDE_HOME === "true" && to.fullPath === "/welcome") { |
| | | next({ path: "/error/404" }); |
| | | next({ path: "/index" }); |
| | | } |
| | | if (_from?.name) { |
| | | // name为超链接 |
| | |
| | | } else { |
| | | if (to.path !== "/login") { |
| | | if (whiteList.indexOf(to.path) !== -1) { |
| | | console.log(to.path, "====1", noLoginList.indexOf(to.path)); |
| | | next(); |
| | | } else { |
| | | removeToken(); |
| | | next({ path: "/login" }); |
| | | // if (noLoginList.indexOf(to.path) == -1) { |
| | | next(); |
| | | // } else { |
| | | // removeToken(); |
| | | // next({ path: "/login" }); |
| | | // } |
| | | } |
| | | } else { |
| | | next(); |