import { useState } from 'react' import { ExhibitOverlay, Title, Image, Cursor, GuideSteps, GuideStepsItem, MultipleChoiceQuizPanel, } from '@/components' import { getBackgroundImage, getPublicPath, getStaticImage } from '@/lib/utils' import { useNavigate, useParams } from 'react-router-dom' import { useChenyunStore, saveChenyunStore } from '@/store/chenyunStore' import { usePuzzleAnimation } from '@/contexts/PuzzleAnimationContext' import { useCursorController } from '@/hooks/useCursorController' import SuccessAlert from '@/components/layout/alert/success-alert' import ScaledPortal from '@/components/layout/ScaledPortal' // 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 { markExhibitVisited, getVisitedExhibits } = useChenyunStore() // 从 store 获取已访问的展品,转换为 Set 用于兼容现有代码 const visitedExhibits = getVisitedExhibits(place) const visited = new Set(visitedExhibits) const { isEnabled } = useCursorController({ initialEnabled: [1], dependencies: { 2: [1] }, visited, }) // 展品1引导对话 const [guideVisible, setGuideVisible] = useState(false) const [guideStep, setGuideStep] = useState(0) // 展品2的引导对话 const [guideVisible2, setGuideVisible2] = useState(false) const [guideStep2, setGuideStep2] = useState(0) // 展品2关闭后的题目状态(多选) const [quiz2Visible, setQuiz2Visible] = useState(false) const [successAlert2Visible, setSuccessAlert2Visible] = useState(false) 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 (