"use client" import { useEffect } from "react" import { X, ChevronLeft, ChevronRight, Check } from "lucide-react" import { frameUrl, type KeyFrame } from "@/lib/api" interface Props { jobId: string frames: KeyFrame[] activeIndex: number | null selected: Set onClose: () => void onChange: (idx: number) => void onToggleSelect: (idx: number) => void } export function FrameLightbox({ jobId, frames, activeIndex, selected, onClose, onChange, onToggleSelect }: Props) { useEffect(() => { if (activeIndex === null) return const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") onClose() if (e.key === "ArrowLeft" && activeIndex > 0) onChange(activeIndex - 1) if (e.key === "ArrowRight" && activeIndex < frames.length - 1) onChange(activeIndex + 1) if (e.key === " " || e.key === "Enter") { e.preventDefault() onToggleSelect(activeIndex) } } window.addEventListener("keydown", onKey) return () => window.removeEventListener("keydown", onKey) }, [activeIndex, frames.length, onClose, onChange, onToggleSelect]) if (activeIndex === null || !frames[activeIndex]) return null const f = frames[activeIndex] const isSelected = selected.has(f.index) return (
{/* 关闭 */} {/* 左右切换 */} {activeIndex > 0 && ( )} {activeIndex < frames.length - 1 && ( )} {/* 大图 */}
e.stopPropagation()} className="flex flex-col items-center gap-4 max-w-[92vw] max-h-[92vh]"> {`frame
{String(f.index + 1).padStart(2, "0")} / {String(frames.length).padStart(2, "0")} · {f.timestamp.toFixed(2)}s
←/→ 切换 · Space 选用 · ESC 关闭
) }