MCPcopy Index your code
hub / github.com/dataease/SQLBot / generateDynamicRouters

Function generateDynamicRouters

frontend/src/router/dynamic.ts:92–121  ·  view source on GitHub ↗
(router: Router)

Source from the content-addressed store, hash-verified

90}
91
92export 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}

Callers 1

watchRouterFunction · 0.90

Calls 4

reduceRoutersFunction · 0.85
forEachMethod · 0.45
findMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected