更新依赖项及历史人物相关内容资源

- 更新 package.json 和 package-lock.json 中的依赖项
- 新增/更新陈云、黄炎培、鲁迅、孙中山的音频文件
- 新增场景和组件的图片资源
- 清理未使用的音频和图片文件
- 优化多个组件和页面的实现逻辑
This commit is contained in:
zhongyidian committed 2026-04-20 13:27:18 +08:00
1 parent b1d55b9464
commit e0fa47d21a
629 files changed
+24390 -2991

No files matched your search

+110 -1
View File
@@ -1,6 +1,14 @@
import { create } from 'zustand'
import { persist } from 'zustand/middleware'
import { STORE_NAMES } from './storeNames'
import { setUserDefine } from '@/lib/utils/api-common'
export interface Clue {
id: string
name: string
collected: boolean
collectedAt?: number
}
interface SunzhongshanStore {
// 存储每个场景(place)的已访问展品ID集合
@@ -10,6 +18,21 @@ interface SunzhongshanStore {
// 体悟模块通用布尔状态(引导是否展示、场景是否完成等)
reflectionFlags: Record<string, boolean>
// 上次访问的场景(place1~place4)
lastVisitedPlace: string | null
setLastVisitedPlace: (place: string) => void
// 体悟模块当前路由(reflection、reflection1、reflection2、reflection3)
reflectionRoute: string
setReflectionRoute: (route: string) => void
// ========== 线索系统(原 clueStore,并入孙中山) ==========
clues: Clue[]
collectClue: (id: string, name: string) => void
isClueCollected: (id: string) => boolean
getSceneClues: (sceneId: string) => Clue[]
resetSceneClues: (sceneId: string) => void
// 标记展品为已访问
markExhibitVisited: (place: string, exhibitId: number) => void
@@ -66,6 +89,9 @@ export const useSunzhongshanStore = create<SunzhongshanStore>()(
(set, get) => ({
visitedExhibits: {},
reflectionFlags: {},
lastVisitedPlace: null,
reflectionRoute: 'reflection',
clues: [],
markExhibitVisited: (place: string, exhibitId: number) => {
set((state) => {
@@ -100,7 +126,13 @@ export const useSunzhongshanStore = create<SunzhongshanStore>()(
},
resetAll: () => {
set({ visitedExhibits: {}, reflectionFlags: {} })
set({
visitedExhibits: {},
reflectionFlags: {},
lastVisitedPlace: null,
reflectionRoute: 'reflection',
clues: [],
})
},
setReflectionFlag: (key: string, value: boolean) => {
@@ -116,12 +148,60 @@ export const useSunzhongshanStore = create<SunzhongshanStore>()(
const { reflectionFlags } = get()
return !!reflectionFlags[key]
},
setLastVisitedPlace: (place: string) => set({ lastVisitedPlace: place }),
setReflectionRoute: (route: string) => set({ reflectionRoute: route }),
collectClue: (id: string, name: string) => {
const { clues } = get()
const existingClue = clues.find((c) => c.id === id)
if (!existingClue) {
set({
clues: [
...clues,
{
id,
name,
collected: true,
collectedAt: Date.now(),
},
],
})
} else if (!existingClue.collected) {
set({
clues: clues.map((c) =>
c.id === id ? { ...c, collected: true, collectedAt: Date.now() } : c
),
})
}
},
isClueCollected: (id: string) => {
const { clues } = get()
return clues.some((c) => c.id === id && c.collected)
},
getSceneClues: (sceneId: string) => {
const { clues } = get()
return clues.filter((c) => c.id.startsWith(sceneId))
},
resetSceneClues: (sceneId: string) => {
const { clues } = get()
set({
clues: clues.filter((c) => !c.id.startsWith(sceneId)),
})
},
}),
{
name: STORE_NAMES.SUNZHONGSHAN,
partialize: (state) => ({
visitedExhibits: serializeVisitedExhibits(state.visitedExhibits),
reflectionFlags: state.reflectionFlags,
lastVisitedPlace: state.lastVisitedPlace,
reflectionRoute: state.reflectionRoute,
clues: state.clues,
}),
onRehydrateStorage: () => (state) => {
if (state) {
@@ -129,8 +209,37 @@ export const useSunzhongshanStore = create<SunzhongshanStore>()(
if (!state.reflectionFlags || typeof state.reflectionFlags !== 'object') {
state.reflectionFlags = {}
}
if (state.lastVisitedPlace === undefined) {
state.lastVisitedPlace = null
}
if (state.reflectionRoute === undefined) {
state.reflectionRoute = 'reflection'
}
if (!(state as any).clues || !Array.isArray((state as any).clues)) {
;(state as any).clues = []
}
}
},
}
)
)
// ========== 易班平台数据保存(对话模块) ==========
export const SUNZHONGSHAN_LESSON_ID = 'Sunzs_duihua'
export const SUNZHONGSHAN_KEY = 4
export const saveSunzhongshanStore = (): void => {
const state = useSunzhongshanStore.getState()
const payload = {
visitedExhibits: serializeVisitedExhibits(state.visitedExhibits),
lastVisitedPlace: state.lastVisitedPlace,
reflectionRoute: state.reflectionRoute,
}
try {
setUserDefine(SUNZHONGSHAN_LESSON_ID, SUNZHONGSHAN_KEY, JSON.stringify(payload))
} catch (error) {
console.error('Failed to save Sunzhongshan store', error)
}
}