diff --git a/sub-operation-service/src/utils/router.js b/sub-operation-service/src/utils/router.js index ce09911..7c80973 100644 --- a/sub-operation-service/src/utils/router.js +++ b/sub-operation-service/src/utils/router.js @@ -109,3 +109,23 @@ export function handleRoutes(routers, pathUrl = '') { 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; +}