mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 03:07:20 +08:00
feat(settings): 禁止隐藏首页和设置页菜单 (#1231)
* Initial plan * feat(settings): 禁止隐藏首页和设置页菜单 Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com> * fix: 修复父子路由禁用状态覆盖问题 Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com> * docs: 改进 forbiddenHiddenMenus 注释说明 Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>
This commit is contained in:
@@ -57,11 +57,16 @@ const channels = [
|
||||
}
|
||||
]
|
||||
|
||||
// 不允许隐藏的菜单项(首页 home/home-index 和设置页 setting/setting-index)
|
||||
const forbiddenHiddenMenus = ['home', 'home-index', 'setting', 'setting-index']
|
||||
|
||||
// 获取菜单选项
|
||||
const getOption = (route: RouteType): TreeSelectOption => {
|
||||
const isDisabled = forbiddenHiddenMenus.includes(route.name as string)
|
||||
let menuItem: TreeSelectOption = {
|
||||
label: route.meta?.title ? translateTitle(route.meta.title) : route.name,
|
||||
key: route.name
|
||||
key: route.name,
|
||||
disabled: isDisabled
|
||||
}
|
||||
|
||||
const visibleChildren = route.children
|
||||
@@ -73,9 +78,12 @@ const getOption = (route: RouteType): TreeSelectOption => {
|
||||
if (visibleChildren.length === 1) {
|
||||
// 单个子路由处理
|
||||
const singleRoute = visibleChildren[0]
|
||||
const isSingleDisabled = forbiddenHiddenMenus.includes(singleRoute.name as string)
|
||||
menuItem.label = singleRoute.meta?.title
|
||||
? translateTitle(singleRoute.meta.title)
|
||||
: singleRoute.name
|
||||
// 父路由或子路由任一被禁止则禁用该菜单项
|
||||
menuItem.disabled = isDisabled || isSingleDisabled
|
||||
const visibleItems = singleRoute.children
|
||||
? singleRoute.children.filter((item: RouteType) => item.name && !item.isHidden)
|
||||
: []
|
||||
|
||||
Reference in New Issue
Block a user