This commit is contained in:
wangzenghua 2025-04-14 02:49:35 +01:00
parent f56bcdba16
commit d24c5d0737

View File

@ -109,3 +109,23 @@ export function handleRoutes(routers, pathUrl = '') {
item.path = path.resolve(pathUrl, item.path); item.path = path.resolve(pathUrl, item.path);
}); });
} }
export function findParentRoute(routes, targetPath) {
for (const route of routes) {
if (route.children) {
for (const child of route.children) {
if (child.path === targetPath) {
return route;
}
if (child.children) {
for (const grandChild of child.children) {
if (grandChild.path === targetPath) {
return child;
}
}
}
}
}
}
return null;
}