Commit 5e374db1 by wanglizhen

路由更改

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