This commit is contained in:
2025-11-14 12:03:02 +08:00
parent e20a7755f8
commit 46003a646e
21 changed files with 887 additions and 499 deletions

View File

@@ -14,6 +14,20 @@ export function getParentChildrenRoutes(route: RouteLocationNormalized): RouteRe
return [];
}
// 返回有 title 的子路由
return parentRoute.children.filter((child: RouteRecordRaw) => child.meta?.title);
// 返回有 title 的子路由但排除父路由本身path 为空字符串或 name 以 _page 结尾的子路由)
return parentRoute.children.filter((child: RouteRecordRaw) => {
// 必须有 title
if (!child.meta?.title) {
return false;
}
// 排除 path 为空字符串的子路由(代表父路由本身)
if (child.path === '' || child.path === undefined) {
return false;
}
// 排除 name 以 _page 结尾的子路由(父路由的默认子路由)
if (typeof child.name === 'string' && child.name.endsWith('_page')) {
return false;
}
return true;
});
}