|
@@ -22,11 +22,18 @@ export const findRouteByPath = (
|
|
|
routes: DageRouteItem[],
|
|
|
path: string
|
|
|
): DageRouteItem | null => {
|
|
|
+ const temp = path.split("/");
|
|
|
+
|
|
|
for (const route of routes) {
|
|
|
- if (route.path === path) {
|
|
|
+ if (route.path.replace(/\/:[^/]+/g, "") === path) {
|
|
|
return route;
|
|
|
}
|
|
|
- if (route.children) {
|
|
|
+ if (
|
|
|
+ // 首层没必要向下遍历
|
|
|
+ temp.length !== 2 &&
|
|
|
+ route.path.indexOf(temp[1]) > -1 &&
|
|
|
+ route.children
|
|
|
+ ) {
|
|
|
const subRoute = findRouteByPath(route.children, path);
|
|
|
if (subRoute) {
|
|
|
return subRoute;
|