feat: 添加断点续读功能,优化用户体验

- 在 chenyunStore 中引入 lastVisitedPlace 和 setLastVisitedPlace 方法,支持记录用户上次访问的场景。
- 在各个场景组件中使用 useEffect 设置 lastVisitedPlace,确保用户在返回时能继续上次访问的地点。
- 更新相关组件,确保在导航时能够正确使用 lastVisitedPlace,提升用户交互体验。
- 在 puzzleStore 中添加保存用户定义的功能,增强数据持久性。
This commit is contained in:
zhongyidian committed 2026-03-06 16:33:44 +08:00
1 parent 76c67b492e
commit b1d55b9464
17 files changed
+147 -54

No files matched your search

+15 -11
View File
@@ -9,7 +9,7 @@ import {
} from '@/components'
import { useNavigate, useParams } from 'react-router-dom'
import { getBackgroundImage, getPublicPath, getStaticImage } from '@/lib/utils'
import { useState } from 'react'
import { useState, useEffect } from 'react'
import Cursor from '@/components/cursor'
import { usePuzzleAnimation } from '@/contexts/PuzzleAnimationContext'
import { useChenyunStore, saveChenyunStore } from '@/store/chenyunStore'
@@ -48,7 +48,11 @@ const ChenyunPlace1 = () => {
// 使用持久化的访问状态
const place = 'place1'
const { markExhibitVisited, getVisitedExhibits } = useChenyunStore()
const { markExhibitVisited, getVisitedExhibits, setLastVisitedPlace } = useChenyunStore()
useEffect(() => {
setLastVisitedPlace(place)
}, [setLastVisitedPlace])
// 从 store 获取已访问的展品,转换为 Set 用于兼容现有代码
const visitedExhibits = getVisitedExhibits(place)
@@ -251,22 +255,22 @@ const ChenyunPlace1 = () => {
const LearningIntroduction = ({ handleStartLearning }: { handleStartLearning: () => void }) => {
return (
<div className="fixed inset-0 z-50 flex items-center justify-center">
<div className="relative w-full h-full bg-gradient-to-b from-[#f5f1e8] via-[#ede8dc] to-[#e8e0d1] shadow-[0_20px_60px_rgba(0,0,0,0.4)] border-4 border-[#d4c5a9] overflow-hidden">
<div className="relative w-full h-full bg-linear-to-b from-[#f5f1e8] via-[#ede8dc] to-[#e8e0d1] shadow-[0_20px_60px_rgba(0,0,0,0.4)] border-4 border-[#d4c5a9] overflow-hidden">
{/* 内容层 */}
<div className="relative h-full w-full p-16 pb-20 overflow-hidden flex flex-col">
{/* 装饰性顶部线条 */}
<div className="absolute top-0 left-0 right-0 h-2 bg-gradient-to-r from-transparent via-[#c9b99b] to-transparent"></div>
<div className="absolute top-0 left-0 right-0 h-2 bg-linear-to-r from-transparent via-[#c9b99b] to-transparent"></div>
{/* 标题 */}
<div className="text-center mb-8 flex-shrink-0">
<div className="text-center mb-8 shrink-0">
<h1 className="text-6xl font-bold text-[#5c4a37] mb-4 tracking-wide">
走进故居-对话模块学习说明
</h1>
<div className="w-32 h-1 bg-gradient-to-r from-transparent via-[#8b7355] to-transparent mx-auto"></div>
<div className="w-32 h-1 bg-linear-to-r from-transparent via-[#8b7355] to-transparent mx-auto"></div>
</div>
{/* 介绍文字 */}
<div className="mb-8 space-y-4 flex-shrink-0">
<div className="mb-8 space-y-4 shrink-0">
<p className="text-3xl text-[#6b5d47] leading-relaxed text-center font-medium">
同学你好,欢迎来到走进故居-对话学习模块!
</p>
@@ -312,7 +316,7 @@ const LearningIntroduction = ({ handleStartLearning }: { handleStartLearning: ()
key={index}
className="flex items-start gap-6 bg-[rgba(255,255,255,0.4)] rounded-xl p-6 border-l-4 border-[#8b7355] mb-4"
>
<span className="flex-shrink-0 w-12 h-12 bg-gradient-to-br from-[#8b7355] to-[#6b5d47] text-white text-3xl font-bold rounded-full flex items-center justify-center shadow-md">
<span className="shrink-0 w-12 h-12 bg-linear-to-br from-[#8b7355] to-[#6b5d47] text-white text-3xl font-bold rounded-full flex items-center justify-center shadow-md">
{index + 1}
</span>
<p className="text-2xl text-[#5c4a37] leading-relaxed flex-1 pt-1">{feature}</p>
@@ -322,13 +326,13 @@ const LearningIntroduction = ({ handleStartLearning }: { handleStartLearning: ()
</div>
{/* 开始学习按钮 */}
<div className="flex justify-center flex-shrink-0">
<div className="flex justify-center shrink-0">
<button
onClick={handleStartLearning}
className="relative cursor-pointer px-20 py-5 bg-gradient-to-r from-[#8b7355] to-[#6b5d47] text-white text-4xl font-bold rounded-2xl shadow-[0_8px_20px_rgba(139,115,85,0.4)] hover:shadow-[0_12px_30px_rgba(139,115,85,0.6)] hover:from-[#9b8365] hover:to-[#7b6d57] transition-all duration-300 active:scale-95 border-2 border-[#a08f75]"
className="relative cursor-pointer px-20 py-5 bg-linear-to-r from-[#8b7355] to-[#6b5d47] text-white text-4xl font-bold rounded-2xl shadow-[0_8px_20px_rgba(139,115,85,0.4)] hover:shadow-[0_12px_30px_rgba(139,115,85,0.6)] hover:from-[#9b8365] hover:to-[#7b6d57] transition-all duration-300 active:scale-95 border-2 border-[#a08f75]"
>
<span className="relative z-10">开始学习</span>
<div className="absolute inset-0 bg-gradient-to-r from-transparent via-white to-transparent opacity-0 hover:opacity-20 rounded-2xl transition-opacity duration-300"></div>
<div className="absolute inset-0 bg-linear-to-r from-transparent via-white to-transparent opacity-0 hover:opacity-20 rounded-2xl transition-opacity duration-300"></div>
</button>
</div>
</div>