Skip to content

Commit

Permalink
fix(utils): getAllParentPaths match error
Browse files Browse the repository at this point in the history
  • Loading branch information
kirklin committed Jan 7, 2024
1 parent d20d335 commit 1c2a3a1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/web/utils/src/menuHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { RouteRecordRaw } from "vue-router";
import { loadDataFromModules } from "./moduleHelper";
import { findFirstNodePath, mapTreeStructure } from "./treeHelper";
import { isHttpUrl } from "./typeChecks";
import { createPathMatcher } from "./router";

/**
* 从模块对象中加载菜单配置并加入到菜单集合中
Expand Down Expand Up @@ -119,10 +120,12 @@ export function transformRouteToMenu(routeModList: RouteRecordRaw[], routerMappi
* @param path The path to match. 要匹配的路径。
* @returns An array of parent paths of the node in the tree that matches the given path. 与给定路径匹配的节点的所有父路径组成的数组。
*/
export function getAllParentPaths<T>(
export function getAllParentPaths<T extends {
path: string;
}>(
treeData: T[],
path: string,
): string[] {
const menuList = findFirstNodePath(treeData, n => n[path] === path) as Menu[];
return menuList?.map(m => m.path);
): string[] | null {
const menuList = findFirstNodePath(treeData, n => createPathMatcher(n.path).test(path));
return menuList?.map(m => m.path) ?? null;
}

2 comments on commit 1c2a3a1

@vercel
Copy link

@vercel vercel bot commented on 1c2a3a1 Jan 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

celeris-web-api – ./services/admin

celeris-web-api.vercel.app
celeris-web-api-git-master-kirklin.vercel.app
celeris-web-api-kirklin.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 1c2a3a1 Jan 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

celeris-web – ./apps/admin

celeris-web.vercel.app
celeris-web-git-master-kirklin.vercel.app
celeris-web-kirklin.vercel.app

Please sign in to comment.