(router: Router)
| 90 | } |
| 91 | |
| 92 | export const generateDynamicRouters = (router: Router) => { |
| 93 | if (userStore.isAdmin || userStore.isSpaceAdmin) { |
| 94 | dynamicRouterList.forEach((item: any) => { |
| 95 | if (!item.parent) { |
| 96 | router.addRoute(item) |
| 97 | } else { |
| 98 | router.addRoute(item.parent, item) |
| 99 | const parentRoute: any = router.getRoutes().find((r: any) => r.name === item.parent) |
| 100 | if (parentRoute?.children) { |
| 101 | parentRoute.children.push(item) |
| 102 | } |
| 103 | } |
| 104 | }) |
| 105 | } else { |
| 106 | const router_name_list = [] as string[] |
| 107 | const stack = [...dynamicRouterList] |
| 108 | while (stack.length) { |
| 109 | const item = stack.pop() |
| 110 | if (item.name) { |
| 111 | router_name_list.push(item.name) |
| 112 | } |
| 113 | if (item.children?.length) { |
| 114 | item.children.forEach((child: any) => { |
| 115 | stack.push(child) |
| 116 | }) |
| 117 | } |
| 118 | } |
| 119 | reduceRouters(router, router_name_list) |
| 120 | } |
| 121 | } |
no test coverage detected