fix: route
parent
e7571ea66c
commit
86642691a3
|
@ -55,6 +55,7 @@ function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) {
|
|||
meta.orderNo = item.sort
|
||||
meta.ignoreKeepAlive = !item.keepAlive
|
||||
item.meta = meta
|
||||
item.name = item.name = item.componentName && item.componentName.length > 0 ? item.componentName : toCamelCase(item.path, true)
|
||||
children && asyncImportRoute(children)
|
||||
})
|
||||
}
|
||||
|
@ -145,7 +146,7 @@ export function transformObjToRoute<T = AppRouteModule>(routeList: AppRouteModul
|
|||
meta.single = true
|
||||
route.children = [cloneDeep(route)]
|
||||
route.component = LAYOUT
|
||||
route.name = `${route.name}Parent`
|
||||
route.name = `${toCamelCase(route.path, true)}Parent`
|
||||
route.path = ''
|
||||
route.meta = meta
|
||||
}
|
||||
|
@ -236,3 +237,17 @@ function isMultipleRoute(routeModule: AppRouteModule) {
|
|||
}
|
||||
return flag
|
||||
}
|
||||
|
||||
function toCamelCase(str: string, upperCaseFirst: boolean) {
|
||||
str = (str || '')
|
||||
.replace(/-(.)/g, function (group1: string) {
|
||||
return group1.toUpperCase()
|
||||
})
|
||||
.replaceAll('-', '')
|
||||
|
||||
if (upperCaseFirst && str) {
|
||||
str = str.charAt(0).toUpperCase() + str.slice(1)
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
import type { AppRouteModule } from '@/router/types'
|
||||
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
|
||||
const menu: AppRouteModule = {
|
||||
path: '/sysmenu',
|
||||
name: 'SysMenu',
|
||||
component: LAYOUT,
|
||||
redirect: '/sysmenu/index',
|
||||
meta: {
|
||||
hideChildrenInMenu: true,
|
||||
icon: 'ant-design:bank-twotone',
|
||||
title: '系统菜单',
|
||||
orderNo: 9999
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'index',
|
||||
name: 'SystemMenu',
|
||||
component: () => import('@/views/system/menu/index.vue'),
|
||||
meta: {
|
||||
title: '系统菜单',
|
||||
icon: 'ant-design:bank-twotone',
|
||||
hideMenu: true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
export default menu
|
|
@ -10,11 +10,12 @@ export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
|
|||
visible?: boolean
|
||||
icon?: string
|
||||
name: string
|
||||
sort: number
|
||||
sort?: number
|
||||
parentId?: number
|
||||
meta: RouteMeta
|
||||
component?: Component | string
|
||||
components?: Component
|
||||
componentName?: string
|
||||
children?: AppRouteRecordRaw[]
|
||||
props?: Recordable
|
||||
fullPath?: string
|
||||
|
|
|
@ -8,7 +8,6 @@ import { useUserStore } from './user'
|
|||
import { useAppStoreWithOut } from './app'
|
||||
import { asyncRoutes } from '@/router/routes'
|
||||
import about from '@/router/routes/modules/about'
|
||||
import menu from '@/router/routes/modules/menu'
|
||||
import dashboard from '@/router/routes/modules/dashboard'
|
||||
import { PAGE_NOT_FOUND_ROUTE } from '@/router/routes/basic'
|
||||
import { transformRouteToMenu } from '@/router/helper/menuHelper'
|
||||
|
@ -228,7 +227,7 @@ export const usePermissionStore = defineStore('app-permission', {
|
|||
|
||||
// Background routing to menu structure
|
||||
// 后台路由到菜单结构
|
||||
const backMenuList = transformRouteToMenu([dashboard, ...routeList, menu, about])
|
||||
const backMenuList = transformRouteToMenu([dashboard, ...routeList, about])
|
||||
this.setBackMenuList(backMenuList)
|
||||
|
||||
// remove meta.ignoreRoute item
|
||||
|
@ -236,7 +235,8 @@ export const usePermissionStore = defineStore('app-permission', {
|
|||
routeList = filter(routeList, routeRemoveIgnoreFilter)
|
||||
routeList = routeList.filter(routeRemoveIgnoreFilter)
|
||||
routeList = flatMultiLevelRoutes(routeList)
|
||||
routes = [PAGE_NOT_FOUND_ROUTE, dashboard, ...routeList, menu, about]
|
||||
routes = [PAGE_NOT_FOUND_ROUTE, dashboard, ...routeList, about]
|
||||
console.info(routes)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue