feat(flowEditor): 为节点添加图标并优化样式
- 在 localNodeData 中添加节点图标 - 在侧边栏中使用 DynamicIcon 组件显示节点图标 -调整节点显示样式,增加图标与名称的间距 - 新增 DynamicIcon 组件,用于动态加载图标master
parent
3bd9bea680
commit
41c1cb5c07
@ -0,0 +1,29 @@
|
||||
import React from 'react';
|
||||
import * as ArcoIcons from '@arco-design/web-react/icon';
|
||||
|
||||
export interface DynamicIconProps {
|
||||
type: string;
|
||||
library?: 'arco'; // 可以扩展支持更多图标库
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
const DynamicIcon: React.FC<DynamicIconProps> = ({
|
||||
type,
|
||||
library = 'arco',
|
||||
...restProps
|
||||
}) => {
|
||||
let IconComponent: React.ComponentType<any> | undefined;
|
||||
|
||||
if (library === 'arco') {
|
||||
IconComponent = ArcoIcons[type as keyof typeof ArcoIcons];
|
||||
} // library 有其他的图标库时可添加
|
||||
|
||||
if (!IconComponent) {
|
||||
console.warn(`Icon '${type}' from library '${library}' not found`);
|
||||
return null;
|
||||
}
|
||||
|
||||
return <IconComponent {...restProps} />;
|
||||
};
|
||||
|
||||
export default DynamicIcon;
|
||||
Loading…
Reference in New Issue