import { ExhibitOverlay, Image, Title, Cursor } from "@/components"; import { useNavigate, useParams } from "react-router-dom"; import { getBackgroundImage, getStaticImage } from "@/lib/utils"; import { useState } from "react"; // starName 固定为 luxun const starName = "luxun"; // 展品 ID 与资源路径映射 const exhibitSrcMap: Record<1 | 2 | 3, string> = { 1: "luxun/place4/展品11", 2: "luxun/place4/展品12", 3: "luxun/place4/展品13", }; const LuxunPlace5 = () => { const navigate = useNavigate(); const { moduleName } = useParams<{ moduleName: string; }>(); const [activeExhibitId, setActiveExhibitId] = useState<1 | 2 | 3 | null>( null ); const [visited, setVisited] = useState>(new Set()); const handleOpenExhibit = (index: 1 | 2 | 3) => { setActiveExhibitId(index); }; const progressCount = visited.size; const total = 3; const completed = progressCount >= total; const subtitle = completed ? "探索鲁迅故居的客房(已完成)" : `探索鲁迅故居的客房(${progressCount}/${total})`; const subtitleClassName = completed ? "text-[#fff998] [text-shadow:_0_8px_8px_rgba(0,0,0,0.35),_0_0_16px_rgba(0,0,0,0.25)]" : undefined; return (
<Image className="absolute right-5 top-5" src={getStaticImage("components/离开")} button onClick={() => { if (moduleName && starName) { navigate(`/${moduleName}/${starName}/place3`); } }} /> {/* 展品 */} <Cursor className="absolute left-167 bottom-30" onClick={() => handleOpenExhibit(1)} read={visited.has(1)} /> <Cursor className="absolute left-228 bottom-30" onClick={() => handleOpenExhibit(2)} read={visited.has(2)} /> <Cursor className="absolute right-115 bottom-18 z-20" onClick={() => handleOpenExhibit(3)} read={visited.has(3)} /> {completed && ( <Image className="absolute bottom-0 right-0" src={getStaticImage("luxun/place4/离开")} button onClick={() => { navigate(`/${moduleName}/${starName}/home`); }} /> )} <ExhibitOverlay visible={activeExhibitId !== null} src={activeExhibitId ? exhibitSrcMap[activeExhibitId] : ""} onClose={() => { if (activeExhibitId !== null) { setVisited((prev) => { const next = new Set(prev); next.add(activeExhibitId); return next; }); } setActiveExhibitId(null); }} /> </div> ); }; export default LuxunPlace5;