/** * PhotoCard Component * Feature: personal-user-enhancements * * Individual photo card with reactions support */ import React from 'react'; import { Button, Checkbox, Dropdown, Menu } from 'antd'; import { DeleteOutlined, DownloadOutlined, EyeOutlined, MoreOutlined, PlayCircleOutlined, } from '@ant-design/icons'; import { ReactionBar } from '@/components/Reactions'; import useReactions from '@/hooks/useReactions'; import { ImageItem } from '@/pages/gallery/typings'; import { formatDuration } from '@/utils/timelineUtils'; import { getAuthization } from '@/utils/userUtils'; interface PhotoCardProps { item: ImageItem; index: number; viewMode: 'small' | 'large'; batchMode: boolean; isSelected: boolean; imageSize: { width: number | string; height: number }; isMobile: boolean; onPreview: (index: number) => void; onSelect: (instanceId: string, checked: boolean) => void; onDownload: (instanceId: string, imageName: string) => void; onDelete: (instanceId: string, imageName: string) => void; } const PhotoCard: React.FC = ({ item, index, viewMode, batchMode, isSelected, imageSize, isMobile, onPreview, onSelect, onDownload, onDelete, }) => { // Initialize reactions for this photo const { reactions, addReaction, updateReaction, removeReaction, actionLoading: reactionLoading, } = useReactions('photo', item.instanceId, { autoFetch: true, autoSubscribe: true, }); // 根据视图模式确定图像 URL const getImageUrl = (isHighRes?: boolean) => { // 如果是视频,使用封面图 if (item.thumbnailInstanceId) { return `/file/image-low-res/${item.thumbnailInstanceId}?Authorization=${getAuthization()}`; } // 小图模式使用低分辨率图像,除非明确要求高清 if (viewMode === 'small' && !isHighRes) { return `/file/image-low-res/${item.instanceId}?Authorization=${getAuthization()}`; } // 其他模式使用原图 return `/file/image/${item.instanceId}?Authorization=${getAuthization()}`; }; const getImageMenu = () => ( } onClick={() => onPreview(index)} > 预览 } onClick={() => onDownload(item.instanceId, item.imageName)} > 下载 } danger onClick={() => onDelete(item.instanceId, item.imageName)} > 删除 ); return (
{batchMode && ( onSelect(item.instanceId, e.target.checked)} /> )}
!batchMode && onPreview(index)} > {(item.duration || item.thumbnailInstanceId) && ( )} {item.duration && ( {formatDuration(item.duration)} )}
{item.imageName}
{/* Reactions */}
e.stopPropagation()} style={{ padding: '4px 8px' }} >
); }; export default PhotoCard;