import { useState } from "react"; import { ExhibitOverlay, Title, Image, Cursor } from "@/components"; import { getBackgroundImage, getStaticImage } from "@/lib/utils"; import { useNavigate, useParams } from "react-router-dom"; const starName = "huangyanpei"; const exhibitSrcMap: Record<1 | 2, string> = { 1: "huangyanpei/place2/4_004", 2: "huangyanpei/place2/4_005", }; const HuangyanpeiPlace2 = () => { const navigate = useNavigate(); const { moduleName } = useParams<{ moduleName: string; }>(); const [activeExhibitId, setActiveExhibitId] = useState<1 | 2 | null>(null); const [visited, setVisited] = useState>(new Set()); const handleOpenExhibit = (index: 1 | 2) => { setActiveExhibitId(index); }; const progressCount = visited.size; const total = 2; 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}/place1`); } }} /> <Cursor className="absolute left-132 top-132" onClick={() => handleOpenExhibit(1)} read={visited.has(1)} /> <Cursor className="absolute left-240 top-132" onClick={() => handleOpenExhibit(2)} read={visited.has(2)} /> {completed && ( <Image className="absolute bottom-0 right-4" src={getStaticImage("components/place/继续前进")} button onClick={() => { navigate(`/${moduleName}/${starName}/place3`); }} /> )} <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 HuangyanpeiPlace2;