create-tengits-app
Version:
🚀 快速创建基于 React + Rsbuild + TypeScript + Tailwind CSS + Antd 的现代前端项目脚手架
124 lines (117 loc) • 3.78 kB
JSX
import React from 'react';
import { TUIIconPark } from 'tengits-ui5';
import { t } from './i18n';
export const getMenus = () => [
{
menuName: t('Home'),
key: '/Home',
icon: <TUIIconPark type="workbench-h7gmkp2e" />,
label: t('Home'),
path: 'Home',
},
// {
// icon: <TUIIconPark type="peoples" />,
// menuName: t('SystemManagement', 'Common'),
// label: t('SystemManagement', 'Common'),
// key: '/systemManagement',
// path: 'systemManagement',
// children: [
// {
// menuName: t('AModel'),
// key: 'modelManage',
// icon: '',
// label: t('Model'),
// path: 'modelManage',
// },
// {
// menuName: t('Evaluation'),
// key: 'evaluation',
// icon: '',
// label: t('Evaluation'),
// path: 'evaluation',
// },
// {
// icon: '',
// menuName: t('UserManagement'),
// label: t('UserManagement'),
// key: 'userManagement',
// path: 'userManagement',
// menuAuth: [{ id: 0, name: '用户管理' }],
// },
// {
// icon: '',
// menuName: t('BasicManagement'),
// label: t('BasicManagement'),
// key: 'basicManagement',
// path: 'basicManagement',
// children: [
// {
// icon: '',
// menuName: t('UserGroupManagement'),
// label: t('UserGroupManagement'),
// key: 'userGroups',
// path: 'userGroups',
// menuAuth: [{ id: 0, name: '用户组管理' }],
// },
// {
// icon: '',
// menuName: t('RoleManagement'),
// label: t('RoleManagement'),
// key: 'roleManagement',
// path: 'roleManagement',
// menuAuth: [{ id: 0, name: '角色管理' }],
// },
// {
// icon: '',
// menuName: t('OperationPermissionManagement'),
// label: t('OperationPermissionManagement'),
// key: 'permissionsManagement',
// path: 'permissionsManagement',
// menuAuth: [{ id: 0, name: '操作权限管理' }],
// },
// {
// icon: '',
// menuName: t('OrganizationalStructureManagement'),
// label: t('OrganizationalStructureManagement'),
// key: 'organizationManagement',
// path: 'organizationManagement',
// menuAuth: [{ id: 0, name: '组织机构管理' }],
// },
// ],
// },
// ],
// },
];
/**
* 树形结构属性替换
* @param item
* @param resetItem 重置某一项的值,item => {}
* @returns
*/
export function replaceMapTree(item, resetItem = it => ({}), level = 1) {
const haveChildren = Array.isArray(item.children) && item.children.length > 0;
const newLevel = level + 1;
return {
...resetItem(item),
menuLevel: newLevel,
children: haveChildren ? item.children.map(itr => replaceMapTree(itr, resetItem, newLevel)) : [],
};
}
/**
* 根据列表权限过滤菜单
*
*/
export function filterMenus(child = []) {
const isHaveList = item => item.menuAuth.find(it => it.name === item.menuName);
const filterChild = child.filter((item) => {
if (item.children && item.children.length)
return filterMenus(item.children).length || isHaveList(item);
else
return isHaveList(item);
}).map((item) => {
if (item.children && item.children.length)
item.children = isHaveList(item) ? item.children : filterMenus(item.children);
return item;
});
return filterChild;
}