import { Popover, Tag, TagProps, Tooltip } from 'antd'; import classNames from 'classnames'; import Image from 'next/image'; import { HtmlHTMLAttributes, PropsWithChildren, ReactNode, memo, useMemo } from 'react'; interface Props { title: string; desc?: string; disabled?: boolean; tags?: ( | string | { text: ReactNode; /** @default false */ border?: boolean; /** @default default */ color?: TagProps['color']; } )[]; operations?: { children: ReactNode; label?: string; onClick?: () => void; }[]; icon?: ReactNode; iconBorder?: boolean; onClick?: () => void; extraContent?: ReactNode; } function GPTCard({ icon, iconBorder = true, title, desc, tags, children, disabled, operations, className, extraContent, ...props }: PropsWithChildren & Props>) { const iconNode = useMemo(() => { if (!icon) return null; if (typeof icon === 'string') { return ( {title} ); } return icon; }, [icon]); // TODO: 算子资源标签 const tagNode = useMemo(() => { if (!tags || !tags.length) return null; return (
{tags.map((tag, index) => { if (typeof tag === 'string') { return ( {tag} ); } return ( {tag.text} ); })}
); }, [tags]); return (
{iconNode}

{title}

{tagNode}
{desc && (

{desc}

)}
{children} {operations && !!operations.length && (
{operations.map((item, index) => (
{ e.stopPropagation(); item.onClick?.(); }} > {item.children} {index < operations.length - 1 && (
)}
))}
)}
{extraContent}
); } export default memo(GPTCard);