refactor: function rename
This commit is contained in:
parent
8f423bea29
commit
b17e7de6ce
|
|
@ -44,6 +44,14 @@ export const dashboardDemoComponentD2FlexMenus = new Menu('Flex')
|
|||
basePath: 'demo/component/d2-flex'
|
||||
}))
|
||||
|
||||
export const dashboardDemoComponentSTableMenus = new Menu('Surely Vue')
|
||||
.icon('icon-park-outline:table-file')
|
||||
.scope('/dashboard/demo/component/s-table')
|
||||
.add(routeMenus({
|
||||
match: /^dashboard-demo-component-s-table/,
|
||||
basePath: 'demo/component/s-table'
|
||||
}))
|
||||
|
||||
export const dashboardDemoComponentMenus = new Menu('组件')
|
||||
.icon('icon-park-outline:components')
|
||||
.add(new Menu('概览').url('/dashboard/demo/component').icon('icon-park-outline:handle-round').index())
|
||||
|
|
@ -52,6 +60,7 @@ export const dashboardDemoComponentMenus = new Menu('组件')
|
|||
.add(dashboardDemoComponentD2IconMenus)
|
||||
.add(dashboardDemoComponentD2BreakPointMenus)
|
||||
.add(dashboardDemoComponentD2FlexMenus)
|
||||
.add(dashboardDemoComponentSTableMenus)
|
||||
|
||||
export const dashboardDemoLayoutDashboardMenus = new Menu('控制台布局')
|
||||
.icon('icon-park-outline:page')
|
||||
|
|
|
|||
|
|
@ -107,11 +107,11 @@ const routesFlat = flattenObjectArray(
|
|||
(item, _) => pick(item, ['name', 'path', 'meta'])
|
||||
)
|
||||
|
||||
function routesFilter (rule) {
|
||||
function filterRoutes (rule) {
|
||||
return routesFlat.filter(route => rule.test(route.name))
|
||||
}
|
||||
|
||||
function routeMenu (route, basePath) {
|
||||
function createRouteMenu (route, basePath) {
|
||||
const url = route.path.replace(RegExp(`^${basePath}`), '')
|
||||
const title = get(route.meta, 'd2admin.menu.title', url || '/')
|
||||
if (!url) {
|
||||
|
|
@ -120,6 +120,9 @@ function routeMenu (route, basePath) {
|
|||
return new Menu(title).url(url)
|
||||
}
|
||||
|
||||
export function routeMenus ({ match = /.+/, basePath = '' } = {}) {
|
||||
return routesFilter(match).map(route => routeMenu(route, basePath))
|
||||
export function routeMenus ({
|
||||
match = /.+/,
|
||||
basePath = ''
|
||||
} = {}) {
|
||||
return filterRoutes(match).map(route => createRouteMenu(route, basePath))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue