管理后台初始化,登录,团队管理,报价单管理 完成
This commit is contained in:
34
src/utils/menuUtils.jsx
Normal file
34
src/utils/menuUtils.jsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import React from 'react';
|
||||
import { routes } from '@/config/routes';
|
||||
import * as AntIcons from '@ant-design/icons';
|
||||
import { ColorIcon } from '@/components/common/ColorIcon';
|
||||
|
||||
|
||||
|
||||
const getAntIcon = (iconName) => {
|
||||
const iconKey = `${iconName.charAt(0).toUpperCase()}${iconName.slice(
|
||||
1
|
||||
)}Outlined`;
|
||||
return AntIcons[iconKey] ? React.createElement(AntIcons[iconKey]) : null;
|
||||
};
|
||||
|
||||
const generateMenuItems = (routes, parentPath = '') => {
|
||||
return routes.map((route) => {
|
||||
const fullPath = `${parentPath}/${route.path}`.replace(/\/+/g, '/');
|
||||
const icon = route.icon && <ColorIcon icon={getAntIcon(route.icon)} />;
|
||||
|
||||
const menuItem = {
|
||||
key: fullPath,
|
||||
icon,
|
||||
label: route.name,
|
||||
};
|
||||
|
||||
if (route.children) {
|
||||
menuItem.children = generateMenuItems(route.children, fullPath);
|
||||
}
|
||||
|
||||
return menuItem;
|
||||
});
|
||||
};
|
||||
|
||||
export const getMenuItems = () => generateMenuItems(routes);
|
||||
Reference in New Issue
Block a user