mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 14:31:41 +08:00
feat(route): add hideChildrenInMenu option close #346
This commit is contained in:
@@ -13,11 +13,15 @@ export function getAllParentPath<T = Recordable>(treeData: T[], path: string) {
|
||||
function joinParentPath(menus: Menu[], parentPath = '') {
|
||||
for (let index = 0; index < menus.length; index++) {
|
||||
const menu = menus[index];
|
||||
const p = menu.path.startsWith('/') ? menu.path : `/${menu.path}`;
|
||||
const parent = isUrl(menu.path) ? menu.path : `${parentPath}${p}`;
|
||||
menus[index].path = parent;
|
||||
// https://next.router.vuejs.org/guide/essentials/nested-routes.html
|
||||
// Note that nested paths that start with / will be treated as a root path.
|
||||
// This allows you to leverage the component nesting without having to use a nested URL.
|
||||
if (!(menu.path.startsWith('/') || isUrl(menu.path))) {
|
||||
// path doesn't start with /, nor is it a url, join parent path
|
||||
menu.path = `${parentPath}/${menu.path}`;
|
||||
}
|
||||
if (menu?.children?.length) {
|
||||
joinParentPath(menu.children, parent);
|
||||
joinParentPath(menu.children, menu.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -66,9 +66,9 @@ export async function getShallowMenus(): Promise<Menu[]> {
|
||||
|
||||
// Get the children of the menu
|
||||
export async function getChildrenMenus(parentPath: string) {
|
||||
const menus = await getAsyncMenus();
|
||||
const menus = await getMenus();
|
||||
const parent = menus.find((item) => item.path === parentPath);
|
||||
if (!parent || !parent.children) return [] as Menu[];
|
||||
if (!parent || !parent.children || !!parent?.meta?.hideChildrenInMenu) return [] as Menu[];
|
||||
const routes = router.getRoutes();
|
||||
|
||||
return !isBackMode() ? filter(parent.children, basicFilter(routes)) : parent.children;
|
||||
|
@@ -11,7 +11,6 @@ const dashboard: AppRouteModule = {
|
||||
meta: {
|
||||
icon: 'ion:grid-outline',
|
||||
title: t('routes.dashboard.dashboard'),
|
||||
hideChildrenInMenu: true,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
|
Reference in New Issue
Block a user