import { Image } from '@/components' import { cn, getBackgroundImage, getStaticImage } from '@/lib/utils' import { useMemo } from 'react' import { useNavigate, useParams } from 'react-router-dom' import { LOBBY_COLUMNS, LOBBY_LAYOUT, LOBBY_TIMELINE, PLACE_REQUIRED_COUNTS } from './lobby.config' import { useNieerStore } from '@/store/nieerStore' import { useDialogReducer } from './useDialogReducer' import DialogLayer from './DialogLayer' const starName = 'nieer' const NieerReflection = () => { const navigate = useNavigate() const { moduleName } = useParams<{ moduleName: string }>() const debugLobby = new URLSearchParams(window.location.search).get('debugLobby') === '1' const visitedReflectionCursors = useNieerStore((state) => state.visitedReflectionCursors) const markReflectionCursorVisited = useNieerStore((state) => state.markReflectionCursorVisited) const setReflectionWork = useNieerStore((state) => state.setReflectionWork) const { state: dialogState, openScene, enterUnlock, handleShare, close, } = useDialogReducer(markReflectionCursorVisited, setReflectionWork) const placeCompletion = useMemo(() => { const getVisitedCount = (placeName: string): number => visitedReflectionCursors[placeName]?.size ?? 0 return { 1: getVisitedCount('place1') >= (PLACE_REQUIRED_COUNTS[1] ?? 0), 2: getVisitedCount('place2') >= (PLACE_REQUIRED_COUNTS[2] ?? 0), 3: getVisitedCount('place3') >= (PLACE_REQUIRED_COUNTS[3] ?? 0), 4: getVisitedCount('place4') >= (PLACE_REQUIRED_COUNTS[4] ?? 0), 5: getVisitedCount('place5') >= (PLACE_REQUIRED_COUNTS[5] ?? 0), 6: getVisitedCount('place6') >= (PLACE_REQUIRED_COUNTS[6] ?? 0), } as const }, [visitedReflectionCursors]) const unlockedById = useMemo( () => ({ 1: true, 2: placeCompletion[1], 3: placeCompletion[2], 4: placeCompletion[3], 5: placeCompletion[4], 6: placeCompletion[5], }) as const, [placeCompletion] ) const badgeUnlocked = useMemo( () => ({ 1: placeCompletion[1] && placeCompletion[2], 2: placeCompletion[3] && placeCompletion[4], 3: placeCompletion[5] && placeCompletion[6], }), [placeCompletion] ) const guideSceneId = useMemo(() => { const nextScene = LOBBY_COLUMNS.find( (scene) => !placeCompletion[scene.id as keyof typeof placeCompletion] ) return nextScene?.id ?? 6 }, [placeCompletion]) const allPlacesCompleted = useMemo( () => LOBBY_COLUMNS.every((scene) => placeCompletion[scene.id as keyof typeof placeCompletion]), [placeCompletion] ) if (!moduleName) return null return (
{/* 返回按钮 */} navigate(`/${moduleName}/${starName}/home`)} /> {/* 六列时间轴内容 */}
{/* 琴弦层:在背景图之上、在顶部图标之下 */} 琴弦 {LOBBY_COLUMNS.map((scene) => { const isUnlocked = unlockedById[scene.id as keyof typeof unlockedById] // 顶部图标只在“该模块已完成学习任务”时亮起;未完成(即当前进度)保持黑白 const isCompleted = placeCompletion[scene.id as keyof typeof placeCompletion] const iconSrc = isCompleted ? scene.icon : scene.iconBw const isClickable = isUnlocked || scene.id === guideSceneId const showGuideState = !allPlacesCompleted && scene.id === guideSceneId return ( ) })}
{/* 横跨年份层:只负责 1937 跨列展示 */}
{LOBBY_TIMELINE.map((item) => { if (item.type === 'single') { return (
{item.label}
) } return (
{item.withLine && } {item.label} {item.withLine && }
) })}
{/* 底部 footer + 徽章区 */}
{[ { id: 1, className: 'top-0 left-36', }, { id: 2, className: 'top-0 left-146', }, { id: 3, className: 'top-0 right-36', }, ].map((i) => { const isLit = badgeUnlocked[i.id as keyof typeof badgeUnlocked] return (
徽章底板 {isLit && ( {`徽章${i.id}`} )}
) })}
{/* 右下角:旅行箱 */} 旅行箱 navigate(`/${moduleName}/${starName}/reflection/box`)} /> {/* debug 参考线 */} {debugLobby && (
)}
) } export default NieerReflection