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.

IconUtil.ts 487 B

1234567891011121314151617181920
  1. import * as AntdIcons from '@ant-design/icons';
  2. import React from 'react';
  3. const allIcons: Record<string, any> = AntdIcons;
  4. export function getIcon(name: string): React.ReactNode | string {
  5. const icon = allIcons[name];
  6. return icon || '';
  7. }
  8. export function createIcon(icon: string | any): React.ReactNode | string {
  9. if (typeof icon === 'object') {
  10. return icon;
  11. }
  12. const ele = allIcons[icon];
  13. if (ele) {
  14. return React.createElement(allIcons[icon]);
  15. }
  16. return '';
  17. }