feat: 引入持久化访问状态管理,优化展品访问逻辑

- 在 Luxun 和 Sunzhongshan 的多个组件中引入 useLuxunStore 和 useSunzhongshanStore,替代原有的访问状态管理方式。
- 通过 markExhibitVisited 方法标记展品为已访问,提升状态管理的效率和一致性。
- 从 store 获取已访问展品的状态,确保数据的持久性和准确性。
This commit is contained in:
zhongyidian committed 2026-02-04 14:01:03 +08:00
1 parent 966b47ede3
commit ac5a2159a1
15 files changed
+392 -173

No files matched your search

+11 -17
View File
@@ -14,6 +14,7 @@ import { getBackgroundImage, getPublicPath, getStaticImage } from "@/lib/utils";
import { useState } from "react";
import { useCursorController } from "@/hooks/useCursorController";
import { usePuzzleAnimation } from "@/contexts/PuzzleAnimationContext";
import { useLuxunStore } from "@/store/luxunStore";
// starName 固定为 luxun
const starName = "luxun";
@@ -47,8 +48,13 @@ const LuxunPlace1 = () => {
const [afterExhibitDialogStep, setAfterExhibitDialogStep] = useState(0);
// 当前激活的展品 ID(只存 ID,不直接存路径,便于作为唯一标识)
const [activeExhibitId, setActiveExhibitId] = useState<1 | 2 | null>(null);
// 已浏览展品的 ID 集合
const [visited, setVisited] = useState<Set<number>>(new Set());
// 使用持久化的访问状态
const place = "place1";
const { markExhibitVisited, getVisitedExhibits } = useLuxunStore();
// 从 store 获取已访问的展品,转换为 Set 用于兼容现有代码
const visitedExhibits = getVisitedExhibits(place);
const visited = new Set(visitedExhibits);
// 连线题显示状态(展品1关闭后)
const [showMatchQuiz, setShowMatchQuiz] = useState(false);
// 连线题成功提示状态
@@ -171,11 +177,7 @@ const LuxunPlace1 = () => {
setShowMatchQuiz(true);
} else {
// 展品2正常标记为已访问
setVisited((prev) => {
const next = new Set(prev);
next.add(activeExhibitId);
return next;
});
markExhibitVisited(place, activeExhibitId);
}
}
setActiveExhibitId(null);
@@ -321,20 +323,12 @@ const LuxunPlace1 = () => {
onContinue={() => {
setShowMatchQuizSuccess(false);
// 标记展品1为已访问
setVisited((prev) => {
const next = new Set(prev);
next.add(1);
return next;
});
markExhibitVisited(place, 1);
}}
onClose={() => {
setShowMatchQuizSuccess(false);
// 标记展品1为已访问
setVisited((prev) => {
const next = new Set(prev);
next.add(1);
return next;
});
markExhibitVisited(place, 1);
}}
/>
</div>
+10 -6
View File
@@ -15,6 +15,7 @@ import { useState } from "react";
import { useCursorController } from "@/hooks/useCursorController";
import { usePuzzleAnimation } from "@/contexts/PuzzleAnimationContext";
import type { DragFillResult } from "@/components";
import { useLuxunStore } from "@/store/luxunStore";
// starName 固定为 luxun
const starName = "luxun";
@@ -38,7 +39,14 @@ const LuxunPlace2 = () => {
const [activeExhibitId, setActiveExhibitId] = useState<1 | 2 | 3 | null>(
null
);
const [visited, setVisited] = useState<Set<number>>(new Set());
// 使用持久化的访问状态
const place = "place2";
const { markExhibitVisited, getVisitedExhibits } = useLuxunStore();
// 从 store 获取已访问的展品,转换为 Set 用于兼容现有代码
const visitedExhibits = getVisitedExhibits(place);
const visited = new Set(visitedExhibits);
// Cursor 顺序控制:1 -> 2 -> 3
const { isEnabled } = useCursorController({
@@ -214,11 +222,7 @@ const LuxunPlace2 = () => {
// }
onClose={() => {
if (activeExhibitId !== null) {
setVisited((prev) => {
const next = new Set(prev);
next.add(activeExhibitId);
return next;
});
markExhibitVisited(place, activeExhibitId);
}
setActiveExhibitId(null);
}}
+15 -31
View File
@@ -13,6 +13,7 @@ import { useState } from "react";
import SuccessAlert from "@/components/layout/alert/success-alert";
import { useCursorController } from "@/hooks/useCursorController";
import { usePuzzleAnimation } from "@/contexts/PuzzleAnimationContext";
import { useLuxunStore } from "@/store/luxunStore";
// starName 固定为 luxun
const starName = "luxun";
@@ -55,7 +56,14 @@ const LuxunPlace3 = () => {
const [activeExhibitId, setActiveExhibitId] = useState<
1 | 2 | 3 | 4 | 5 | null
>(null);
const [visited, setVisited] = useState<Set<number>>(new Set());
// 使用持久化的访问状态
const place = "place3";
const { markExhibitVisited, getVisitedExhibits } = useLuxunStore();
// 从 store 获取已访问的展品,转换为 Set 用于兼容现有代码
const visitedExhibits = getVisitedExhibits(place);
const visited = new Set(visitedExhibits);
// Cursor 顺序控制:1 -> 2 -> 3 -> 4 -> 5
const { isEnabled } = useCursorController({
@@ -259,11 +267,7 @@ const LuxunPlace3 = () => {
} else {
// 其他光标:正常关闭并标记为已读
if (activeExhibitId !== null) {
setVisited((prev) => {
const next = new Set(prev);
next.add(activeExhibitId);
return next;
});
markExhibitVisited(place, activeExhibitId);
}
setActiveExhibitId(null);
}
@@ -277,11 +281,7 @@ const LuxunPlace3 = () => {
setGuide1Visible(visible);
if (!visible) {
// 对话关闭时,标记光标1为已读
setVisited((prev) => {
const next = new Set(prev);
next.add(1);
return next;
});
markExhibitVisited(place, 1);
}
}}
currentStep={guide1Step}
@@ -383,11 +383,7 @@ const LuxunPlace3 = () => {
onContinue={() => {
setSuccessAlert2Visible(false);
// 标记光标2为已读
setVisited((prev) => {
const next = new Set(prev);
next.add(2);
return next;
});
markExhibitVisited(place, 2);
}}
/>
@@ -398,11 +394,7 @@ const LuxunPlace3 = () => {
setGuide3Visible(visible);
if (!visible) {
// 对话关闭时,标记光标3为已读
setVisited((prev) => {
const next = new Set(prev);
next.add(3);
return next;
});
markExhibitVisited(place, 3);
}
}}
currentStep={guide3Step}
@@ -432,11 +424,7 @@ const LuxunPlace3 = () => {
setGuide4Visible(visible);
if (!visible) {
// 对话关闭时,标记光标4为已读
setVisited((prev) => {
const next = new Set(prev);
next.add(4);
return next;
});
markExhibitVisited(place, 4);
}
}}
currentStep={guide4Step}
@@ -496,11 +484,7 @@ const LuxunPlace3 = () => {
onContinue={() => {
setSuccessAlert5Visible(false);
// 标记光标5为已读
setVisited((prev) => {
const next = new Set(prev);
next.add(5);
return next;
});
markExhibitVisited(place, 5);
// 打开光标5的引导对话
setGuide5Visible(true);
setGuide5Step(0);
+14 -18
View File
@@ -16,6 +16,7 @@ import { useState, useRef, useMemo } from "react";
import SuccessAlert from "@/components/layout/alert/success-alert";
import { useCursorController } from "@/hooks/useCursorController";
import { usePuzzleAnimation } from "@/contexts/PuzzleAnimationContext";
import { useLuxunStore } from "@/store/luxunStore";
// starName 固定为 luxun
const starName = "luxun";
@@ -54,7 +55,14 @@ const LuxunPlace5 = () => {
const [activeExhibitId, setActiveExhibitId] = useState<1 | 2 | 3 | null>(
null
);
const [visited, setVisited] = useState<Set<number>>(new Set());
// 使用持久化的访问状态
const place = "place4";
const { markExhibitVisited, getVisitedExhibits } = useLuxunStore();
// 从 store 获取已访问的展品,转换为 Set 用于兼容现有代码
const visitedExhibits = getVisitedExhibits(place);
const visited = new Set(visitedExhibits);
// Cursor 顺序控制:1 -> 2 -> 3
const { isEnabled } = useCursorController({
@@ -252,13 +260,9 @@ const LuxunPlace5 = () => {
setActiveExhibitId(null);
return;
}
setVisited((prev) => {
const next = new Set(prev);
if (activeExhibitId !== null) {
next.add(activeExhibitId);
}
return next;
});
if (activeExhibitId !== null) {
markExhibitVisited(place, activeExhibitId);
}
setActiveExhibitId(null);
}}
/>
@@ -327,11 +331,7 @@ const LuxunPlace5 = () => {
content="1933年,瞿秋白夫妇第三次到鲁迅家避难,就住进了这间仅6平方米的客房,与鲁迅常常彻夜长谈革命与文学。"
onContinue={() => {
setSuccessAlertVisible(false);
setVisited((prev) => {
const next = new Set(prev);
next.add(2);
return next;
});
markExhibitVisited(place, 2);
}}
/>
@@ -341,11 +341,7 @@ const LuxunPlace5 = () => {
onVisibleChange={(visible) => {
setGuide3Visible(visible);
if (!visible) {
setVisited((prev) => {
const next = new Set(prev);
next.add(3);
return next;
});
markExhibitVisited(place, 3);
}
}}
currentStep={guide3Step}
+16 -34
View File
@@ -17,6 +17,7 @@ import { SuccessAlert, DragQuizPanel } from "@/components/layout";
import { MultipleChoiceQuizPanel } from "@/components/layout/quiz";
import { useCursorController } from "@/hooks/useCursorController";
import { usePuzzleAnimation } from "@/contexts/PuzzleAnimationContext";
import { useSunzhongshanStore } from "@/store/sunzhongshanStore";
// starName 固定为 sunzhongshan
const starName = "sunzhongshan";
@@ -50,8 +51,13 @@ const SunzhongshanPlace1 = () => {
const [activeExhibitId, setActiveExhibitId] = useState<
1 | 2 | 3 | 4 | 5 | null
>(null);
// 已浏览展品的 ID 集合
const [visited, setVisited] = useState<Set<number>>(new Set());
// 使用持久化的访问状态
const place = "place1";
const { markExhibitVisited, getVisitedExhibits } = useSunzhongshanStore();
// 从 store 获取已访问的展品,转换为 Set 用于兼容现有代码
const visitedExhibits = getVisitedExhibits(place);
const visited = new Set(visitedExhibits);
// 展品2窗口关闭的对话状态
const [guide2CloseVisible, setGuide2CloseVisible] = useState(false);
@@ -256,11 +262,7 @@ const SunzhongshanPlace1 = () => {
return;
}
if (currentId !== null) {
setVisited((prev) => {
const next = new Set(prev);
next.add(currentId);
return next;
});
markExhibitVisited(place, currentId);
}
setActiveExhibitId(null);
}}
@@ -328,11 +330,7 @@ const SunzhongshanPlace1 = () => {
onVisibleChange={(nextVisible) => {
setGuide2Visible(nextVisible);
if (!nextVisible) {
setVisited((prev) => {
const next = new Set(prev);
next.add(2);
return next;
});
markExhibitVisited(place, 2);
}
}}
showMask={false}
@@ -386,11 +384,7 @@ const SunzhongshanPlace1 = () => {
onVisibleChange={(nextVisible) => {
setGuide5Visible(nextVisible);
if (!nextVisible) {
setVisited((prev) => {
const next = new Set(prev);
next.add(5);
return next;
});
markExhibitVisited(place, 5);
}
}}
showMask={false}
@@ -514,11 +508,7 @@ const SunzhongshanPlace1 = () => {
onContinue={() => {
setSuccessAlert4Visible(false);
// setShowVideo4Second(true);
setVisited((prev) => {
const next = new Set(prev);
next.add(4);
return next;
});
markExhibitVisited(place, 4);
}}
onClose={() => {
setSuccessAlert4Visible(false);
@@ -536,8 +526,8 @@ const SunzhongshanPlace1 = () => {
showSkipButton
onEnded={() => {
setShowVideo4Second(false);
setVisited((prev) => new Set([...prev, 3]));
// 视频播放结束后,标记展品3为已访问
markExhibitVisited(place, 3);
}}
/>
)}
@@ -645,20 +635,12 @@ const SunzhongshanPlace1 = () => {
onContinue={() => {
setSuccessAlert1Visible(false);
// 修改cursor状态
setVisited((prev) => {
const next = new Set(prev);
next.add(1);
return next;
});
markExhibitVisited(place, 1);
}}
onClose={() => {
setSuccessAlert1Visible(false);
// 修改cursor状态
setVisited((prev) => {
const next = new Set(prev);
next.add(1);
return next;
});
markExhibitVisited(place, 1);
}}
/>
</div>
+12 -16
View File
@@ -13,6 +13,7 @@ import { useCursorController } from "@/hooks/useCursorController";
import { getBackgroundImage, getPublicPath, getStaticImage } from "@/lib/utils";
import { useNavigate, useParams } from "react-router-dom";
import { usePuzzleAnimation } from "@/contexts/PuzzleAnimationContext";
import { useSunzhongshanStore } from "@/store/sunzhongshanStore";
const starName = "sunzhongshan";
@@ -35,7 +36,14 @@ const SunzhongshanPlace2 = () => {
const [activeExhibitId, setActiveExhibitId] = useState<1 | 2 | 3 | 4 | null>(
null
);
const [visited, setVisited] = useState<Set<number>>(new Set());
// 使用持久化的访问状态
const place = "place2";
const { markExhibitVisited, getVisitedExhibits } = useSunzhongshanStore();
// 从 store 获取已访问的展品,转换为 Set 用于兼容现有代码
const visitedExhibits = getVisitedExhibits(place);
const visited = new Set(visitedExhibits);
// Cursor 顺序控制:1 -> 2 -> 3 -> 4
const { isEnabled } = useCursorController({
@@ -186,11 +194,7 @@ const SunzhongshanPlace2 = () => {
// 光标4:正常关闭,更新visited状态
}
if (currentId !== null) {
setVisited((prev) => {
const next = new Set(prev);
next.add(currentId);
return next;
});
markExhibitVisited(place, currentId);
}
setActiveExhibitId(null);
}}
@@ -237,11 +241,7 @@ const SunzhongshanPlace2 = () => {
onEnded={() => {
setShowVideo1(false);
// 修改cursor状态
setVisited((prev) => {
const next = new Set(prev);
next.add(1);
return next;
});
markExhibitVisited(place, 1);
}}
/>
)}
@@ -287,11 +287,7 @@ const SunzhongshanPlace2 = () => {
onEnded={() => {
setShowVideo2(false);
// 修改cursor状态
setVisited((prev) => {
const next = new Set(prev);
next.add(2);
return next;
});
markExhibitVisited(place, 2);
}}
/>
)}
+14 -18
View File
@@ -15,6 +15,7 @@ import { getBackgroundImage, getPublicPath, getStaticImage } from "@/lib/utils";
import { useNavigate, useParams } from "react-router-dom";
import { SuccessAlert, DragQuizPanel } from "@/components/layout";
import { usePuzzleAnimation } from "@/contexts/PuzzleAnimationContext";
import { useSunzhongshanStore } from "@/store/sunzhongshanStore";
const starName = "sunzhongshan";
@@ -37,7 +38,14 @@ const SunzhongshanPlace3 = () => {
const [activeExhibitId, setActiveExhibitId] = useState<1 | 2 | 3 | 4 | null>(
null
);
const [visited, setVisited] = useState<Set<number>>(new Set());
// 使用持久化的访问状态
const place = "place3";
const { markExhibitVisited, getVisitedExhibits } = useSunzhongshanStore();
// 从 store 获取已访问的展品,转换为 Set 用于兼容现有代码
const visitedExhibits = getVisitedExhibits(place);
const visited = new Set(visitedExhibits);
// Cursor 顺序控制:1 -> 2 -> 3 -> 4
const { isEnabled } = useCursorController({
@@ -195,11 +203,7 @@ const SunzhongshanPlace3 = () => {
}
if (currentId !== null) {
setVisited((prev) => {
const next = new Set(prev);
next.add(currentId);
return next;
});
markExhibitVisited(place, currentId);
}
setActiveExhibitId(null);
}}
@@ -338,22 +342,14 @@ const SunzhongshanPlace3 = () => {
<SuccessAlert
visible={successAlert2Visible}
onContinue={() => {
setSuccessAlert2Visible(false);
// 修改cursor状态
setVisited((prev) => {
const next = new Set(prev);
next.add(2);
return next;
});
setSuccessAlert2Visible(false);
// 修改cursor状态
markExhibitVisited(place, 2);
}}
onClose={() => {
setSuccessAlert2Visible(false);
// 修改cursor状态
setVisited((prev) => {
const next = new Set(prev);
next.add(2);
return next;
});
markExhibitVisited(place, 2);
}}
/>
+11 -11
View File
@@ -14,6 +14,7 @@ import { useCursorController } from "@/hooks/useCursorController";
import { getBackgroundImage, getStaticImage, getPublicPath } from "@/lib/utils";
import { useNavigate, useParams } from "react-router-dom";
import { usePuzzleAnimation } from "@/contexts/PuzzleAnimationContext";
import { useSunzhongshanStore } from "@/store/sunzhongshanStore";
const starName = "sunzhongshan";
@@ -39,7 +40,14 @@ const SunzhongshanPlace4 = () => {
const [showInitialDialog, setShowInitialDialog] = useState(true);
const [initialDialogStep, setInitialDialogStep] = useState(0);
const [activeExhibitId, setActiveExhibitId] = useState<1 | 2 | null>(null);
const [visited, setVisited] = useState<Set<number>>(new Set());
// 使用持久化的访问状态
const place = "place4";
const { markExhibitVisited, getVisitedExhibits } = useSunzhongshanStore();
// 从 store 获取已访问的展品,转换为 Set 用于兼容现有代码
const visitedExhibits = getVisitedExhibits(place);
const visited = new Set(visitedExhibits);
// Cursor 顺序控制:1 -> 2
const { isEnabled } = useCursorController({
@@ -143,11 +151,7 @@ const SunzhongshanPlace4 = () => {
}
if (currentId !== null) {
setVisited((prev) => {
const next = new Set(prev);
next.add(currentId);
return next;
});
markExhibitVisited(place, currentId);
}
setActiveExhibitId(null);
}}
@@ -177,11 +181,7 @@ const SunzhongshanPlace4 = () => {
onContinue={() => {
setShowVideo1Guide(false);
// 学习引导关闭后,修改cursor状态
setVisited((prev) => {
const next = new Set(prev);
next.add(1);
return next;
});
markExhibitVisited(place, 1);
}}
animationSpeed={200}
audioSrc={getPublicPath("audio/sunzhongshan/mp3_sunzhongshan_46.mp3")}
+16 -12
View File
@@ -2,6 +2,7 @@ import { useState, useEffect } from "react";
import { useNavigate, useParams } from "react-router-dom";
import { Image, StudyGuideModal } from "@/components";
import { getBackgroundImage, getPublicPath, getStaticImage } from "@/lib/utils";
import { useSunzhongshanStore } from "@/store/sunzhongshanStore";
const starName = "sunzhongshan";
const GUIDE_STORAGE_KEY = `${starName}-reflection-guide-shown`;
@@ -24,17 +25,19 @@ const SunzhongshanReflection = () => {
scene3: false,
});
const { getReflectionFlag, setReflectionFlag } = useSunzhongshanStore();
// 检查场景完成状态 - 每次组件挂载或从场景页面返回时重新检查
const checkSceneCompleted = () => {
const scene1Completed =
localStorage.getItem(`${starName}-reflection-scene1-completed`) ===
"true";
const scene2Completed =
localStorage.getItem(`${starName}-reflection-scene2-completed`) ===
"true";
const scene3Completed =
localStorage.getItem(`${starName}-reflection-scene3-completed`) ===
"true";
const scene1Completed = getReflectionFlag(
`${starName}-reflection-scene1-completed`
);
const scene2Completed = getReflectionFlag(
`${starName}-reflection-scene2-completed`
);
const scene3Completed = getReflectionFlag(
`${starName}-reflection-scene3-completed`
);
setSceneCompleted({
scene1: scene1Completed,
@@ -55,15 +58,16 @@ const SunzhongshanReflection = () => {
return () => {
document.removeEventListener("visibilitychange", handleVisibilityChange);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
// 检查是否是第一次进入,显示学习引导
useEffect(() => {
const hasShownGuide = localStorage.getItem(GUIDE_STORAGE_KEY);
const hasShownGuide = getReflectionFlag(GUIDE_STORAGE_KEY);
if (!hasShownGuide) {
setShowGuide(true);
}
}, []);
}, [getReflectionFlag]);
// 检查场景是否可解锁
const isSceneUnlocked = (sceneNumber: number): boolean => {
@@ -82,7 +86,7 @@ const SunzhongshanReflection = () => {
const handleGuideClose = () => {
setShowGuide(false);
localStorage.setItem(GUIDE_STORAGE_KEY, "true");
setReflectionFlag(GUIDE_STORAGE_KEY, true);
};
const handleStartExplore = () => {
+6 -4
View File
@@ -15,6 +15,7 @@ import { getBackgroundImage, getStaticImage, getPublicPath } from "@/lib/utils";
import { useClueStore } from "@/store/clueStore";
import type { ClueHint } from "@/components/clue";
import { usePuzzleAnimation } from "@/contexts/PuzzleAnimationContext";
import { useSunzhongshanStore } from "@/store/sunzhongshanStore";
const starName = "sunzhongshan";
const sceneId = `${starName}/reflection/scene1`;
@@ -69,9 +70,10 @@ const SunzhongshanReflectionScene1 = () => {
const { moduleName } = useParams<{
moduleName: string;
}>();
// 获取碎片动画触发方法
const { triggerPuzzleAnimation } = usePuzzleAnimation();
const { getReflectionFlag, setReflectionFlag } = useSunzhongshanStore();
const [showClueHint, setShowClueHint] = useState(false);
const [showClueBook, setShowClueBook] = useState(false);
@@ -179,7 +181,7 @@ const SunzhongshanReflectionScene1 = () => {
const handleVideoEnd = () => {
setShowVideo(false);
// 检查是否需要显示学习引导
const hasShownGuide = localStorage.getItem(GUIDE_STORAGE_KEY);
const hasShownGuide = getReflectionFlag(GUIDE_STORAGE_KEY);
if (!hasShownGuide) {
setShowGuide(true);
}
@@ -188,7 +190,7 @@ const SunzhongshanReflectionScene1 = () => {
// 处理学习引导关闭
const handleGuideClose = () => {
setShowGuide(false);
localStorage.setItem(GUIDE_STORAGE_KEY, "true");
setReflectionFlag(GUIDE_STORAGE_KEY, true);
};
// 检查是否所有线索都已收集
@@ -240,7 +242,7 @@ const SunzhongshanReflectionScene1 = () => {
const handleCompleteGuideClose = () => {
setShowCompleteGuide(false);
// 保存场景1完成状态
localStorage.setItem(`${starName}-reflection-scene1-completed`, "true");
setReflectionFlag(`${starName}-reflection-scene1-completed`, true);
if (moduleName && starName) {
navigate(`/${moduleName}/${starName}/reflection2`);
}
+5 -3
View File
@@ -15,6 +15,7 @@ import { getBackgroundImage, getStaticImage, getPublicPath } from "@/lib/utils";
import { useClueStore } from "@/store/clueStore";
import type { ClueHint } from "@/components/clue";
import { usePuzzleAnimation } from "@/contexts/PuzzleAnimationContext";
import { useSunzhongshanStore } from "@/store/sunzhongshanStore";
const starName = "sunzhongshan";
const sceneId = `${starName}/reflection/scene2`;
@@ -82,6 +83,7 @@ const SunzhongshanReflectionScene2 = () => {
// 获取碎片动画触发方法
const { triggerPuzzleAnimation } = usePuzzleAnimation();
const { getReflectionFlag, setReflectionFlag } = useSunzhongshanStore();
const [showClueHint, setShowClueHint] = useState(false);
const [showClueBook, setShowClueBook] = useState(false);
@@ -189,7 +191,7 @@ const SunzhongshanReflectionScene2 = () => {
const handleVideoEnd = () => {
setShowVideo(false);
// 检查是否需要显示学习引导
const hasShownGuide = localStorage.getItem(GUIDE_STORAGE_KEY);
const hasShownGuide = getReflectionFlag(GUIDE_STORAGE_KEY);
if (!hasShownGuide) {
setShowGuide(true);
}
@@ -198,7 +200,7 @@ const SunzhongshanReflectionScene2 = () => {
// 处理学习引导关闭
const handleGuideClose = () => {
setShowGuide(false);
localStorage.setItem(GUIDE_STORAGE_KEY, "true");
setReflectionFlag(GUIDE_STORAGE_KEY, true);
};
// 检查是否所有线索都已收集
@@ -250,7 +252,7 @@ const SunzhongshanReflectionScene2 = () => {
const handleCompleteGuideClose = () => {
setShowCompleteGuide(false);
// 保存场景2完成状态
localStorage.setItem(`${starName}-reflection-scene2-completed`, "true");
setReflectionFlag(`${starName}-reflection-scene2-completed`, true);
if (moduleName && starName) {
navigate(`/${moduleName}/${starName}/reflection3`);
}
+5 -3
View File
@@ -16,6 +16,7 @@ import { getBackgroundImage, getStaticImage, getPublicPath } from "@/lib/utils";
import { useClueStore } from "@/store/clueStore";
import type { ClueHint } from "@/components/clue";
import { usePuzzleAnimation } from "@/contexts/PuzzleAnimationContext";
import { useSunzhongshanStore } from "@/store/sunzhongshanStore";
const starName = "sunzhongshan";
const sceneId = `${starName}/reflection/scene3`;
@@ -73,6 +74,7 @@ const SunzhongshanReflectionScene3 = () => {
// 获取碎片动画触发方法
const { triggerPuzzleAnimation } = usePuzzleAnimation();
const { getReflectionFlag, setReflectionFlag } = useSunzhongshanStore();
const [showClueHint, setShowClueHint] = useState(false);
const [showClueBook, setShowClueBook] = useState(false);
@@ -202,7 +204,7 @@ const SunzhongshanReflectionScene3 = () => {
const handleVideoEnd = () => {
setShowVideo(false);
// 检查是否需要显示学习引导
const hasShownGuide = localStorage.getItem(GUIDE_STORAGE_KEY);
const hasShownGuide = getReflectionFlag(GUIDE_STORAGE_KEY);
if (!hasShownGuide) {
setShowGuide(true);
}
@@ -211,7 +213,7 @@ const SunzhongshanReflectionScene3 = () => {
// 处理学习引导关闭
const handleGuideClose = () => {
setShowGuide(false);
localStorage.setItem(GUIDE_STORAGE_KEY, "true");
setReflectionFlag(GUIDE_STORAGE_KEY, true);
};
// 检查是否所有线索都已收集
@@ -262,7 +264,7 @@ const SunzhongshanReflectionScene3 = () => {
const handleCompleteGuideClose = () => {
setShowCompleteGuide(false);
// 保存场景3完成状态
localStorage.setItem(`${starName}-reflection-scene3-completed`, "true");
setReflectionFlag(`${starName}-reflection-scene3-completed`, true);
if (moduleName && starName) {
navigate(`/${moduleName}/${starName}/home`);
}