"use client"; import { useEffect, useRef } from "react"; import Image from "next/image"; import { BookOpen } from "lucide-react"; import gsap from "gsap"; interface ReadingData { title: string; author: string; quote: string; progress: number; pageDesc: string; coverUrl?: string; } export default function ReadingCard({ data }: { data?: ReadingData }) { const title = data?.title || "The Order of Time"; const author = data?.author || "ROVELLI"; const quote = data?.quote || "“世界不是物体的集合,而是事件的集合。从时间跨度来看,世界在流动。”"; const progress = data?.progress !== undefined ? data.progress : 68; const pageDesc = data?.pageDesc || "Page 204/300"; const coverUrl = data?.coverUrl || ""; const cardRef = useRef(null); const bookRef = useRef(null); const progressRef = useRef(null); useEffect(() => { // 初始化 3D 图书姿态 if (bookRef.current) { gsap.set(bookRef.current, { transformPerspective: 1000, rotationY: -22, rotationX: 10, rotationZ: -2, }); } }, []); const handleMouseEnter = () => { // 1. 书本翻转与悬浮 gsap.to(bookRef.current, { rotationY: -8, rotationX: 15, y: -10, duration: 0.6, ease: "power2.out", }); // 2. 进度条波光扫过 gsap.fromTo( progressRef.current, { xPercent: -100 }, { xPercent: 0, duration: 0.85, ease: "power2.out" } ); }; const handleMouseLeave = () => { // 1. 书本恢复 gsap.to(bookRef.current, { rotationY: -22, rotationX: 10, y: 0, duration: 0.6, ease: "power2.out", }); }; return (
{/* 精致小角饰 */}
{/* 顶部标签 */}
Reading / 正在阅读
{/* 图书 3D 展示区域 */}
{/* 左侧杂志排版文字 */}
{author}

{title.startsWith("《") ? title : `《${title}》`}

{title === "The Order of Time" ? (

L'ordine del tempo

) : (

IN PROGRESS

)}
{/* 右侧 3D 图书 */}
{/* 3D 旋转容器 */}
{/* 书本封底 (Back Cover) - 深色 */}
{/* 书页厚度 (Pages Thickness) */}
{/* 书脊 (Spine) */}
{/* 书本封面 (Front Cover) */}
{coverUrl ? ( {title} ) : (
{/* 封面艺术线条 (星轨示意) */}
{author}
{title}
)}
{/* 名言段落与进度条 */}

{quote}

{/* 进度控制槽 */}
Progress / 进度 {progress}% ({pageDesc})
{/* 静态已读进度条 */}
{/* 悬停闪光交互条 */}
); }