import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' import './index.css' import App from './App' import { useChenyunStore, useHuangyanpeiStore, usePuzzleStore, useClueStore } 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() useClueStore.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( )