Files
shanghai-residences/src/main.tsx
T
zhongyidian e0fa47d21a 更新依赖项及历史人物相关内容资源
- 更新 package.json 和 package-lock.json 中的依赖项
- 新增/更新陈云、黄炎培、鲁迅、孙中山的音频文件
- 新增场景和组件的图片资源
- 清理未使用的音频和图片文件
- 优化多个组件和页面的实现逻辑
2026-04-20 13:27:18 +08:00

73 lines
2.2 KiB
TypeScript

import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App'
import { useChenyunStore, useHuangyanpeiStore, usePuzzleStore, useSunzhongshanStore } from './store'
// 在开发模式的移动端启用 vConsole(需先安装 vconsole 依赖)
if (import.meta.env.DEV && typeof window !== 'undefined') {
const ua = window.navigator.userAgent.toLowerCase()
const isMobile = /iphone|ipad|ipod|android|mobile/.test(ua)
if (isMobile) {
// 动态加载,避免生产环境打包 & 未安装时报错
import('vconsole')
.then((mod) => {
const VConsole = (mod as any).default || (mod as any)
new VConsole()
})
.catch(() => {
// vconsole 未安装或加载失败时静默忽略
})
}
}
// 全局键盘快捷键:Ctrl+Shift+R 重置所有缓存
const setupGlobalKeyboardShortcuts = () => {
if (typeof window !== 'undefined') {
document.addEventListener('keydown', (event) => {
// Ctrl+Shift+R: 重置所有缓存
if (event.ctrlKey && event.shiftKey && event.key === 'R') {
event.preventDefault() // 阻止默认的页面刷新行为
// 显示确认对话框
const confirmed = window.confirm(
'确定要重置所有缓存吗?这将清除所有已收集的拼图碎片、已完成的展品和线索。'
)
if (confirmed) {
try {
// 重置所有store
useChenyunStore.getState().resetAll()
useHuangyanpeiStore.getState().resetAll()
usePuzzleStore.getState().resetAll()
useSunzhongshanStore.getState().resetAll()
// 显示成功消息
alert('所有缓存已重置!页面将刷新。')
window.location.reload()
} catch (error) {
console.error('重置缓存时出错:', error)
alert('重置缓存失败,请查看控制台错误信息。')
}
}
}
})
}
}
// 设置全局键盘快捷键
setupGlobalKeyboardShortcuts()
const rootElement = document.getElementById('root')
if (!rootElement) {
throw new Error('Root element not found')
}
createRoot(rootElement).render(
<StrictMode>
<App />
</StrictMode>
)