update route

This commit is contained in:
Dede Fuji Abdul
2023-10-20 08:55:05 +07:00
parent db38765126
commit a66b1bde49
2 changed files with 75 additions and 8 deletions

View File

@ -30,11 +30,31 @@ const convertToDashedString = (input: string): string => {
return `/${parts.join('-')}`;
}
// export const convertRouteToMenu = (data: RouteRecordRaw[], basePath: string = '/home', iconIndex: number = 0): MenuItemModel[] => {
// return data.filter((i) => i.path !== '').map((item) => {
// const convertedItem: MenuItemModel = {
// name: item.name?.toString() || '',
// path: convertToDashedString(`${basePath}/${item.path}`).replace('/home-', '/home/'),
// expanded: false,
// icon: undefined,
// children: [],
// };
// if (item.children) {
// convertedItem.icon = navigationIcon[iconIndex];
// iconIndex = (iconIndex + 1) % navigationIcon.length;
// convertedItem.children = convertRouteToMenu(item.children, `${basePath}/${item.path}`, iconIndex);
// }
// return convertedItem
// })
// }
export const convertRouteToMenu = (data: RouteRecordRaw[], basePath: string = '/home', iconIndex: number = 0): MenuItemModel[] => {
return data.filter((i) => i.path !== '').map((item) => {
const convertedItem: MenuItemModel = {
name: item.name?.toString() || '',
path: convertToDashedString(`${basePath}/${item.path}`).replace('/home-', '/home/'),
path: `${basePath}/${item.path}`,
expanded: false,
icon: undefined,
children: [],