'use client' import React, { useCallback } from 'react' import Link from 'next/link' import { format } from 'date-fns' import { Switch } from '@/components/ui/switch' import { MemberNameWithStatus } from '@/components/member-name-with-status' import { Play, Video } from 'lucide-react' interface PhotoCardProps { photo: { url: string caption?: string uploadedAt: string memberId: string memberName: string isDead: boolean adminVisibleOverride: boolean visibleInOverview: boolean } isOwner: boolean | null currentTree?: { id?: string } | null onSelect: (url: string) => void onToggle: (memberId: string, photoUrl: string, value: boolean) => void isLoading: boolean } const isVideoFile = (url: string) => { const videoExtensions = ['.mp4', '.webm', '.ogg', '.mov', '.avi', '.mkv'] return videoExtensions.some(ext => url.toLowerCase().endsWith(ext)) } export const PhotoCard: React.FC = ({ photo, isOwner, currentTree, onSelect, onToggle, isLoading }) => { const handleToggle = useCallback((checked: boolean) => { onToggle(photo.memberId, photo.url, checked) }, [photo.memberId, photo.url, onToggle]) if (photo.adminVisibleOverride === false) { return (
来自
{format(new Date(photo.uploadedAt), 'MM-dd')}
{isOwner && (
允许展示
)} {!isOwner && (

管理员已隐藏

)}
) } return (
{/* 媒体区域 */}
onSelect(photo.url)} > {isVideoFile(photo.url) ? (
) : ( {photo.caption )}
{/* 底部信息 */}
{/* 照片说明 */}
{photo.caption ? ( {photo.caption} ) : ( 暂无说明 )}
{/* 分享人和时间 */}
来自
{format(new Date(photo.uploadedAt), 'MM-dd')}
{/* 管理员权限开关 */} {isOwner && (
允许展示
)}
) }