mirror of https://gitee.com/xiaonuobase/snowy
【更新】优化登录无角色用户的显示
parent
3bb2de5244
commit
5062c92b9f
|
@ -25,7 +25,7 @@ const routes = {
|
|||
children: []
|
||||
}
|
||||
],
|
||||
// 默认首页为个人中心
|
||||
// 默认谁都有个人中心
|
||||
menu: [
|
||||
{
|
||||
id: '001',
|
||||
|
@ -36,8 +36,7 @@ const routes = {
|
|||
title: '个人中心',
|
||||
type: 'menu',
|
||||
hidden: true
|
||||
},
|
||||
children: []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -107,10 +107,9 @@ router.beforeEach(async (to, from, next) => {
|
|||
if (apiMenu.length === 0) {
|
||||
// 创建默认模块,显示默认菜单
|
||||
apiMenu[0] = cloneDeep(userRoutes.module[0])
|
||||
const userMenu = userRoutes.menu
|
||||
const childrenApiMenu = apiMenu[0].children
|
||||
apiMenu[0].children = [...userMenu, ...childrenApiMenu]
|
||||
}
|
||||
const childrenApiMenu = apiMenu[0].children
|
||||
apiMenu[0].children = [...childrenApiMenu ? childrenApiMenu : [], ...userRoutes.menu]
|
||||
let menuRouter = filterAsyncRouter(apiMenu)
|
||||
menuRouter = flatAsyncRoutes(menuRouter)
|
||||
menuRouter.forEach((item) => {
|
||||
|
@ -147,10 +146,9 @@ router.getMenu = () => {
|
|||
if (apiMenu.length === 0) {
|
||||
// 创建默认模块,显示默认菜单
|
||||
apiMenu[0] = cloneDeep(userRoutes.module[0])
|
||||
const userMenu = userRoutes.menu
|
||||
const childrenApiMenu = apiMenu[0].children
|
||||
apiMenu[0].children = [...userMenu, ...childrenApiMenu]
|
||||
}
|
||||
const childrenApiMenu = apiMenu[0].children
|
||||
apiMenu[0].children = [...childrenApiMenu ? childrenApiMenu : [], ...userRoutes.menu]
|
||||
return filterUrl(apiMenu)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,14 +8,20 @@
|
|||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
import userRoutes from '@/config/route'
|
||||
|
||||
// 获取第一个界面
|
||||
const getIndexMenu = (menu) => {
|
||||
let indexMenu = menu[0].children[0]
|
||||
// 如果第一个菜单为目录,接着往下找
|
||||
if (indexMenu.meta.type === 'catalog') {
|
||||
indexMenu = traverseChild(menu)
|
||||
if (menu[0] && menu[0].children) {
|
||||
let indexMenu = menu[0].children[0]
|
||||
// 如果第一个菜单为目录,接着往下找
|
||||
if (indexMenu.meta.type === 'catalog') {
|
||||
indexMenu = traverseChild(menu)
|
||||
}
|
||||
return indexMenu
|
||||
} else {
|
||||
return userRoutes.menu[0]
|
||||
}
|
||||
return indexMenu
|
||||
}
|
||||
// 遍历进行判断,其中处理了被隐藏的
|
||||
const traverseChild = (menu) => {
|
||||
|
|
Loading…
Reference in New Issue