'use client'; // ImageLightbox — 点击挑图卡片放大看全图(解决"只看半截"),ESC/点遮罩关闭 import { useEffect } from 'react'; interface ImageLightboxProps { url: string | null; caption?: string; onClose: () => void; } export function ImageLightbox({ url, caption, onClose }: ImageLightboxProps) { useEffect(() => { if (!url) return; const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', onKey); // 打开时锁滚动,关闭时恢复 const prev = document.body.style.overflow; document.body.style.overflow = 'hidden'; return () => { window.removeEventListener('keydown', onKey); document.body.style.overflow = prev; }; }, [url, onClose]); if (!url) return null; return (
e.stopPropagation()}> {/* 原图按真实比例完整展示,不裁切 */} {caption {caption && (

{caption}

)}
); }