"use client" import { useState } from "react" import Image from "next/image" import { TimelineStats } from "@/components/timeline-stats" import { Card, CardContent } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { Calendar, MapPin, Camera } from "lucide-react" interface Photo { id: number src: string title: string description: string category: string tags: string[] date: string exif: { camera: string lens: string settings: string location: string } } interface TimelineViewProps { photos: Photo[] onPhotoClick: (photo: Photo) => void } export function TimelineView({ photos, onPhotoClick }: TimelineViewProps) { const [loadedImages, setLoadedImages] = useState>(new Set()) const handleImageLoad = (photoId: number) => { setLoadedImages((prev) => new Set(prev).add(photoId)) } // Group photos by year and month const groupedPhotos = photos .sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()) .reduce( (acc, photo) => { const date = new Date(photo.date) const year = date.getFullYear() const month = date.getMonth() if (!acc[year]) { acc[year] = {} } if (!acc[year][month]) { acc[year][month] = [] } acc[year][month].push(photo) return acc }, {} as Record>, ) const monthNames = [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月", ] return (
{/* Timeline line */}
{Object.entries(groupedPhotos).map(([year, months]) => (
{/* Year marker */}
{year}
{Object.entries(months).map(([monthIndex, monthPhotos]) => (
{/* Month marker */}
{monthNames[Number.parseInt(monthIndex)]}
{/* Photos for this month */}
{monthPhotos.map((photo, index) => (
{/* Timeline dot */}
{/* Photo card */}
onPhotoClick(photo)} >
{!loadedImages.has(photo.id) && (
)} {photo.title} handleImageLoad(photo.id)} />

{photo.title}

{photo.description}

{photo.tags.slice(0, 3).map((tag) => ( {tag} ))}
{photo.date}
{photo.exif.location}
{photo.exif.camera}
))}
))}
))}
) }