Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
chore: 路由守卫,路由树过滤函数增加备注
Browse files Browse the repository at this point in the history
  • Loading branch information
jinmao88 committed Oct 24, 2023
1 parent 67b7d73 commit c607ca9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions apps/admin/src/router/routes/modules/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ const test: RouteRecordItem = {
title: 'Test',
collapsedShowTitle: true,
},
children: [
{
path: 'test',
name: 'ttest',
component: () => import('@/pages/test/test.vue'),
meta: {
icon: 'mdi:monitor-dashboard',
title: 'Test2',
collapsedShowTitle: true,
},
},
],
},
],
}
Expand Down
3 changes: 2 additions & 1 deletion apps/admin/src/store/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ export const useAuthStore = defineStore('app-auth-store', {
}
// 组合框架路由 与 本地路由
const r = layoutRoutes.concat(asyncRoutes)
routes = filterRouterTree(r, routeFilter)
// 过滤路由树,扁平化false
routes = filterRouterTree(r, routeFilter, false)
switch (permissionMode) {
case PermissionModeEnum.ROLE:
// routes = filterTree(r, routeFilter)
Expand Down
2 changes: 2 additions & 0 deletions packages/router/src/helper/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ function isMultipleRoute(routeModule: RouteRecordItem) {
return flag
}

// 路由树过滤函数
// flat参数是否扁平化
export function filterRouterTree<T = any>(
tree: T[],
func: (n: T) => boolean,
Expand Down

0 comments on commit c607ca9

Please sign in to comment.