feat: add puzzle residence configuration and reflection progress logic

- Introduced `puzzleResidences.ts` to define puzzle residence configurations including properties like display name, position, and puzzle availability.
- Added `reflectionProgress.ts` to manage badge unlocking logic based on place completion, including functions to determine unlocked badges and video sources for scenes.
This commit is contained in:
zhongyidian committed 2026-04-27 11:49:30 +08:00
1 parent e0fa47d21a
commit f5f36f75b5
153 files changed
+3846 -2352

No files matched your search

+13
View File
@@ -51,6 +51,10 @@ interface NieerStore {
reflectionWorks: Record<number, Record<string, unknown>>
setReflectionWork: (sceneId: number, payload: Record<string, unknown>) => void
resetReflectionWorks: () => void
// 是否已经看过体悟首页学习引导
hasSeenReflectionGuide: boolean
markReflectionGuideSeen: () => void
}
// 将 Set 转换为数组以便序列化
@@ -129,6 +133,7 @@ export const useNieerStore = create<NieerStore>()(
// ========== 体悟模块状态 ==========
visitedReflectionCursors: {},
reflectionWorks: {},
hasSeenReflectionGuide: false,
markReflectionCursorVisited: (scene: string, cursorId: number) => {
set((state) => {
@@ -182,6 +187,10 @@ export const useNieerStore = create<NieerStore>()(
resetReflectionWorks: () => {
set({ reflectionWorks: {} })
},
markReflectionGuideSeen: () => {
set({ hasSeenReflectionGuide: true })
},
}),
{
name: STORE_NAMES.NIEER,
@@ -190,6 +199,7 @@ export const useNieerStore = create<NieerStore>()(
visitedReflectionCursors: serializeVisitedExhibits(state.visitedReflectionCursors),
lastVisitedPlace: state.lastVisitedPlace,
reflectionWorks: state.reflectionWorks,
hasSeenReflectionGuide: state.hasSeenReflectionGuide,
}),
onRehydrateStorage: () => (state) => {
if (state) {
@@ -203,6 +213,9 @@ export const useNieerStore = create<NieerStore>()(
if (!state.reflectionWorks || typeof state.reflectionWorks !== 'object') {
state.reflectionWorks = {}
}
if ((state as any).hasSeenReflectionGuide === undefined) {
;(state as any).hasSeenReflectionGuide = false
}
}
},
}
+9 -1
View File
@@ -31,6 +31,7 @@ interface ZhanglepingStore {
// 绘制模块提交结果(用于在 scene5 画板处展示)
drawArtworkDataUrl: string
drawArtworkCaption: string
hasDrawArtwork: boolean
setDrawArtwork: (dataUrl: string, caption: string) => void
clearDrawArtwork: () => void
@@ -69,6 +70,7 @@ export const useZhanglepingStore = create<ZhanglepingStore>()(
visitedReflectionCursors: {},
drawArtworkDataUrl: '',
drawArtworkCaption: '',
hasDrawArtwork: false,
hasSeenStudyGuide: false,
markExhibitVisited: (place: string, exhibitId: number) => {
@@ -125,12 +127,14 @@ export const useZhanglepingStore = create<ZhanglepingStore>()(
set({
drawArtworkDataUrl: dataUrl,
drawArtworkCaption: caption,
hasDrawArtwork: true,
}),
clearDrawArtwork: () =>
set({
drawArtworkDataUrl: '',
drawArtworkCaption: '',
hasDrawArtwork: false,
}),
markStudyGuideSeen: () => set({ hasSeenStudyGuide: true }),
@@ -144,6 +148,7 @@ export const useZhanglepingStore = create<ZhanglepingStore>()(
visitedReflectionCursors: serializeVisited(state.visitedReflectionCursors),
drawArtworkDataUrl: state.drawArtworkDataUrl,
drawArtworkCaption: state.drawArtworkCaption,
hasDrawArtwork: state.hasDrawArtwork,
hasSeenStudyGuide: state.hasSeenStudyGuide,
}),
onRehydrateStorage: () => (state) => {
@@ -162,6 +167,9 @@ export const useZhanglepingStore = create<ZhanglepingStore>()(
if ((state as any).drawArtworkCaption === undefined) {
;(state as any).drawArtworkCaption = ''
}
if ((state as any).hasDrawArtwork === undefined) {
;(state as any).hasDrawArtwork = Boolean((state as any).drawArtworkDataUrl)
}
if ((state as any).hasSeenStudyGuide === undefined) {
;(state as any).hasSeenStudyGuide = false
}
@@ -188,7 +196,7 @@ export const saveZhanglepingStore = (): void => {
visitedReflectionCursors: serializeVisited(state.visitedReflectionCursors),
drawArtworkDataUrl: remoteArtworkDataUrl,
drawArtworkCaption: state.drawArtworkCaption,
hasDrawArtwork: Boolean(state.drawArtworkDataUrl),
hasDrawArtwork: state.hasDrawArtwork,
}
try {