更新TypeScript配置和Vite配置,新增模块路径别名支持,同时优化数据库初始化逻辑,提升代码可读性和结构。
This commit is contained in:
@@ -7,25 +7,16 @@ import dayjs from "dayjs";
|
||||
import "dayjs/locale/zh-cn";
|
||||
import App from "./App";
|
||||
import "./styles/global.scss";
|
||||
import { db } from "@/utils/db"; // 引入数据库实例
|
||||
import { db } from "./utils/db"; // 引入数据库实例
|
||||
|
||||
// 设置dayjs为中文
|
||||
dayjs.locale("zh-cn");
|
||||
|
||||
// 数据库初始化
|
||||
async function initializeApp() {
|
||||
try {
|
||||
// 确保数据库已打开
|
||||
await db.open();
|
||||
|
||||
await db.kfUsers.clear();
|
||||
await db.weChatGroup.clear();
|
||||
await db.contracts.clear();
|
||||
await db.newContractList.clear();
|
||||
} catch (error) {
|
||||
console.error("数据库初始化失败:", error);
|
||||
// 可以选择显示错误提示或使用降级方案
|
||||
}
|
||||
// 确保数据库已打开
|
||||
await db.open();
|
||||
console.log("数据库初始化成功");
|
||||
|
||||
// 渲染应用
|
||||
const root = createRoot(document.getElementById("root")!);
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
"@/*": ["src/*"],
|
||||
"@weChatStore/*": ["src/store/module/weChat/*"],
|
||||
"@storeModule/*": ["src/store/module/*"],
|
||||
"@apiModule/*": ["src/api/module/*"]
|
||||
"@apiModule/*": ["src/api/module/*"],
|
||||
"@utils/*": ["src/utils/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src"]
|
||||
|
||||
@@ -10,6 +10,7 @@ export default defineConfig({
|
||||
"@storeModule": path.resolve("src/store/module/"),
|
||||
"@weChatStore": path.resolve("src/store/module/weChat"),
|
||||
"@apiModule": path.resolve("src/api/module/"),
|
||||
"@utils": path.resolve("src/utils/"),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
|
||||
Reference in New Issue
Block a user