feat: 更新 ESLint 和 Prettier 配置,增强代码质量管理
- 在 .gitignore 中添加 public/audio/* 以忽略音频文件。 - 更新 bun.lock,添加 eslint-config-prettier 和 eslint-plugin-prettier 依赖,确保 ESLint 与 Prettier 的兼容性。 - 修改 eslint.config.ts,整合 Prettier 规则,优化代码风格一致性。 - 在 package.json 中添加 lint:fix 和 format 脚本,简化代码格式化和修复流程。 - 更新 tailwind.config.ts 和其他组件文件,统一代码风格,提升可读性。
This commit is contained in:
1 parent
5d00adc1a5
commit
76c67b492e
216 files changed
+12454
-13976
No files matched your search
+33
-38
@@ -1,77 +1,72 @@
|
||||
import { StrictMode } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import "./index.css";
|
||||
import App from "./App";
|
||||
import {
|
||||
useChenyunStore,
|
||||
useHuangyanpeiStore,
|
||||
usePuzzleStore,
|
||||
useClueStore,
|
||||
} from "./store";
|
||||
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 (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")
|
||||
import('vconsole')
|
||||
.then((mod) => {
|
||||
const VConsole = (mod as any).default || (mod as any);
|
||||
// eslint-disable-next-line no-new
|
||||
new VConsole();
|
||||
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) => {
|
||||
if (typeof window !== 'undefined') {
|
||||
document.addEventListener('keydown', (event) => {
|
||||
// Ctrl+Shift+R: 重置所有缓存
|
||||
if (event.ctrlKey && event.shiftKey && event.key === "R") {
|
||||
event.preventDefault(); // 阻止默认的页面刷新行为
|
||||
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();
|
||||
useChenyunStore.getState().resetAll()
|
||||
useHuangyanpeiStore.getState().resetAll()
|
||||
usePuzzleStore.getState().resetAll()
|
||||
useClueStore.getState().resetAll()
|
||||
|
||||
// 显示成功消息
|
||||
alert("所有缓存已重置!页面将刷新。");
|
||||
window.location.reload();
|
||||
alert('所有缓存已重置!页面将刷新。')
|
||||
window.location.reload()
|
||||
} catch (error) {
|
||||
console.error("重置缓存时出错:", error);
|
||||
alert("重置缓存失败,请查看控制台错误信息。");
|
||||
console.error('重置缓存时出错:', error)
|
||||
alert('重置缓存失败,请查看控制台错误信息。')
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 设置全局键盘快捷键
|
||||
setupGlobalKeyboardShortcuts();
|
||||
setupGlobalKeyboardShortcuts()
|
||||
|
||||
const rootElement = document.getElementById("root");
|
||||
const rootElement = document.getElementById('root')
|
||||
if (!rootElement) {
|
||||
throw new Error("Root element not found");
|
||||
throw new Error('Root element not found')
|
||||
}
|
||||
|
||||
createRoot(rootElement).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>
|
||||
);
|
||||
)
|
||||
Reference in new issue
Block a user