@@ -2,7 +2,8 @@ import React from 'react';
22import { message , Tree , TreeSelect , Upload } from 'antd' ;
33import { StructKit } from '@/_utils' ;
44import { FileInfo , TreeNode } from '@/_types' ;
5- import * as ICONS from '@ant-design/icons' ;
5+ import * as Icons from '@ant-design/icons' ;
6+ import { BuildOutlined } from '@ant-design/icons' ;
67
78export default class UIKit {
89 public static COLUMN_PREFIX = 'hui.' ;
@@ -32,10 +33,14 @@ export default class UIKit {
3233 public static getIcon ( name ?: string | JSX . Element ) : JSX . Element {
3334 if ( ! name || typeof name === 'object' ) return name as any ;
3435 const IconMap : Record < string , any > = {
35- default : ICONS [ 'BuildOutlined' ] ,
36+ // @ts -ignore
37+ default : < BuildOutlined /> ,
3638 } ;
37- let Element = IconMap [ name ] ;
38- return React . createElement ( Element ?? ICONS [ name ] , { } ) ;
39+ let element = IconMap [ name ] ;
40+ if ( element ) {
41+ return element ;
42+ }
43+ return < Iconfont icon = { name } /> ;
3944 }
4045
4146 /**
@@ -179,3 +184,13 @@ export default class UIKit {
179184 return meetType && meetSize ;
180185 } ;
181186}
187+
188+ const Iconfont = ( props ) => {
189+ //这里传入的props是一个对象,里面有icon属性,值是antd图标的名字
190+ const { icon } = props ;
191+ let iconObj = Icons [ icon ] ;
192+ if ( ! iconObj ) {
193+ return < > </ > ;
194+ }
195+ return React . createElement ( iconObj ) ;
196+ } ;
0 commit comments