import { useState } from "react"; import { ExhibitOverlay, Title, Image, Cursor, GuideSteps, GuideStepsItem, StudyGuideModal, } from "@/components"; import { getBackgroundImage, getStaticImage } from "@/lib/utils"; import { useNavigate, useParams } from "react-router-dom"; import { useChenyunStore } from "@/store/chenyunStore"; import { usePuzzleAnimation } from "@/contexts/PuzzleAnimationContext"; // starName 固定为 chenyun const starName = "chenyun"; // 展品 ID 与资源路径映射 const exhibitSrcMap: Record<1 | 2, string> = { 1: "chenyun/place4/场景4展品1", 2: "chenyun/place4/场景4展品2", }; const ChenyunPlace4 = () => { const navigate = useNavigate(); const { moduleName } = useParams<{ moduleName: string; }>(); // 获取碎片动画触发方法 const { triggerPuzzleAnimation } = usePuzzleAnimation(); const [activeExhibitId, setActiveExhibitId] = useState<1 | 2 | null>(null); // 使用持久化的访问状态 const place = "place4"; const { isExhibitVisited, markExhibitVisited, getVisitedExhibits } = useChenyunStore(); // 从 store 获取已访问的展品,转换为 Set 用于兼容现有代码 const visitedExhibits = getVisitedExhibits(place); const visited = new Set(visitedExhibits); // 展品1引导对话 const [guideVisible, setGuideVisible] = useState(false); const [guideStep, setGuideStep] = useState(0); // 展品2的引导对话 const [guideVisible2, setGuideVisible2] = useState(false); const [guideStep2, setGuideStep2] = useState(0); // 学习引导弹窗 const [showGuideModal, setShowGuideModal] = useState(true); const handleOpenExhibit = (index: 1 | 2) => { if (index === 1) { // 展品1:点击时同时打开展品和引导对话 setActiveExhibitId(1); setGuideVisible(true); setGuideStep(0); } else { // 展品2:点击时同时打开展品和引导对话 setActiveExhibitId(2); setGuideVisible2(true); setGuideStep2(0); } }; // 监听GuideSteps步骤变化,仅同步当前步骤 const handleGuideStepChange = (step: number) => { setGuideStep(step); }; const handleGuideStepChange2 = (step: number) => { setGuideStep2(step); }; 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 (