|
@@ -65,30 +65,49 @@ export const generateRoute = (routes: AppCustomRouteRecordRaw[]): AppRouteRecord
|
|
|
redirect: route.redirect,
|
|
|
meta: meta
|
|
|
}
|
|
|
-
|
|
|
- if (route.children) {
|
|
|
+
|
|
|
+ if (!route.children && route.parentId == 0 && route.component) {
|
|
|
data.component = Layout
|
|
|
- data.redirect = getRedirect(route.path, route.children)
|
|
|
-
|
|
|
- } else if (isUrl(route.path)) {
|
|
|
- data = {
|
|
|
- path: '/external-link',
|
|
|
- component: Layout,
|
|
|
- meta: {
|
|
|
- name: route.name
|
|
|
- },
|
|
|
- children: [data]
|
|
|
- } as AppRouteRecordRaw
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
+ data.meta = {}
|
|
|
+ data.name = toCamelCase(route.path, true) + 'Parent'
|
|
|
+ data.redirect = ''
|
|
|
+ const childrenData: AppRouteRecordRaw = {
|
|
|
+ path: '',
|
|
|
+ name: toCamelCase(route.path, true),
|
|
|
+ redirect: route.redirect,
|
|
|
+ meta: meta
|
|
|
+ }
|
|
|
const index = route?.component
|
|
|
? modulesRoutesKeys.findIndex((ev) => ev.includes(route.component))
|
|
|
: modulesRoutesKeys.findIndex((ev) => ev.includes(route.path))
|
|
|
- data.component = modules[modulesRoutesKeys[index]]
|
|
|
- }
|
|
|
- if (route.children) {
|
|
|
- data.children = generateRoute(route.children)
|
|
|
+ childrenData.component = modules[modulesRoutesKeys[index]]
|
|
|
+ data.children = [childrenData]
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if (route.children) {
|
|
|
+ data.component = Layout
|
|
|
+ data.redirect = getRedirect(route.path, route.children)
|
|
|
+
|
|
|
+ } else if (isUrl(route.path)) {
|
|
|
+ data = {
|
|
|
+ path: '/external-link',
|
|
|
+ component: Layout,
|
|
|
+ meta: {
|
|
|
+ name: route.name
|
|
|
+ },
|
|
|
+ children: [data]
|
|
|
+ } as AppRouteRecordRaw
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ const index = route?.component
|
|
|
+ ? modulesRoutesKeys.findIndex((ev) => ev.includes(route.component))
|
|
|
+ : modulesRoutesKeys.findIndex((ev) => ev.includes(route.path))
|
|
|
+ data.component = modules[modulesRoutesKeys[index]]
|
|
|
+ }
|
|
|
+ if (route.children) {
|
|
|
+ data.children = generateRoute(route.children)
|
|
|
+ }
|
|
|
}
|
|
|
res.push(data)
|
|
|
}
|