import { CaretDownOutlined, CaretRightOutlined, MinusSquareOutlined, PlusSquareOutlined, } from '@ant-design/icons'; import Link from 'antd/lib/typography/Link'; import type { CSSProperties } from 'react'; export interface ExpandIconProps { expanded: boolean; onExpand: (record: T, e: React.MouseEvent) => void; record: T; style?: CSSProperties; /** 使用高级图标 */ useSenior?: boolean; /** 图标是否受数据控制 */ dataControl?: boolean; } const ExpandIcon = (props: ExpandIconProps) => { const { expanded, onExpand, record, style, useSenior = false, dataControl = true } = props; if (dataControl && (!record.children || record.children.length === 0)) { return null; // 如果没有数据,返回 null 不渲染展开图标 } const expandIcon = useSenior ? : ; const foldIcon = useSenior ? : ; return ( onExpand(record, e)}> {expanded ? expandIcon : foldIcon} ); }; export default ExpandIcon;