Skip to content

Commit aa93088

Browse files
author
hocgin
committed
dev
1 parent 9dc0cc5 commit aa93088

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

src/_utils/kit.ui.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import React from 'react';
22
import { message, Tree, TreeSelect, Upload } from 'antd';
33
import { StructKit } from '@/_utils';
44
import { 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

78
export 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

Comments
 (0)