Commit 5e374db1 by wanglizhen

路由更改

parent d8324e52
......@@ -21,10 +21,10 @@ const isWhiteList = (path) => {
let isGeneratingRoutes = false
router.beforeEach((to, from, next) => {
changeMenu(to)
NProgress.start()
if (getToken()) {
changeMenu(to)
to.meta.title && useSettingsStore().setTitle(to.meta.title)
/* has token*/
if (to.path === '/login') {
......@@ -81,8 +81,12 @@ router.beforeEach((to, from, next) => {
// 监听路由变化更换菜单
const changeMenu = (to) => {
console.log(to)
const { path } = to;
const navList = JSON.parse(sessionStorage.getItem('navList')) || [];
if(path === '/' || path === ''){
router.push({ path: navList[0].url})
}
if (navList.length === 0) return;
const menuObj = navList.find((item) => {
const itemPath = item.submenu.length > 0 ? `/${path.split('/').filter(Boolean)[0]}` : path;
......
......@@ -57,19 +57,6 @@ export const constantRoutes = [
component: () => import('@/views/error/401'),
hidden: true
},
// {
// path: '',
// component: Layout,
// redirect: '/index',
// children: [
// {
// path: '/index',
// component: () => import('@/views/index'),
// name: 'Index',
// meta: { title: '首页', icon: 'home', affix: true }
// }
// ]
// },
{
path: '/user',
component: Layout,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论