import React from 'react' import type { Attachment } from '../../types' import { getFileIconConfig } from '../../utils/fileIcons' export interface AttachmentItemProps { attachment: Attachment onClick?: (attachment: Attachment) => void } /** * 附件展示组件 */ export function AttachmentItem({ attachment, onClick }: AttachmentItemProps) { const handleClick = (e: React.MouseEvent) => { if (onClick) { e.preventDefault() onClick(attachment) } } const fileTypeFromMeta = attachment.file_type?.split('/')?.at(-1) ?? attachment.file_type const extFromName = attachment.file_name.split('.').pop() || '' const { icon: Icon, color } = getFileIconConfig(fileTypeFromMeta || extFromName) return ( {attachment.file_name} ) }