You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

menuRender.tsx 1.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * @Author: 赵伟
  3. * @Date: 2024-05-11 15:40:58
  4. * @Description: 自定义菜单项
  5. */
  6. import KFIcon from '@/components/KFIcon';
  7. import { MenuDataItem } from '@ant-design/pro-components';
  8. import { Link } from '@umijs/max';
  9. export const menuItemRender = (isSubMenu: boolean) => {
  10. return (item: MenuDataItem) => {
  11. const defaultIcon: string = item.icon as string;
  12. const activeIcon = defaultIcon + '-active';
  13. const hasParent = item.pro_layout_parentKeys?.length > 0;
  14. const childen = (
  15. <>
  16. {!hasParent && defaultIcon && (
  17. <>
  18. <KFIcon type={defaultIcon} font={17} className="kf-menu-item__default-icon" />
  19. <KFIcon type={activeIcon} font={17} className="kf-menu-item__active-icon" />
  20. </>
  21. )}
  22. <span className="kf-menu-item__name">{item.name}</span>
  23. </>
  24. );
  25. if (isSubMenu) {
  26. return <div className="kf-menu-item">{childen}</div>;
  27. } else if (item.isUrl) {
  28. return (
  29. <a href={item.path || ''} target="_blank" className="kf-menu-item" rel="noreferrer">
  30. {childen}
  31. </a>
  32. );
  33. } else {
  34. return (
  35. <Link to={item.path || ''} className="kf-menu-item">
  36. {childen}
  37. </Link>
  38. );
  39. }
  40. };
  41. };