fix: db was not auto created

This commit is contained in:
Ou
2025-03-04 13:31:57 +08:00
parent 75c0f22fd5
commit 099a840d4c
5 changed files with 1342 additions and 1590 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ import { ourongxing, react } from "@ourongxing/eslint-config"
export default ourongxing({
type: "app",
// 貌似不能 ./ 开头,
ignores: ["src/routeTree.gen.ts", "imports.app.d.ts", "public/", ".vscode"],
ignores: ["src/routeTree.gen.ts", "imports.app.d.ts", "public/", ".vscode", "**/*.json"],
}).append(react({
files: ["src/**"],
}))
+1 -1
View File
@@ -14,7 +14,7 @@ const nitroOption: Parameters<typeof viteNitro>[0] = {
sourceMap: false,
database: {
default: {
connector: "sqlite",
connector: "better-sqlite3",
},
},
imports: {
+15 -5
View File
@@ -104,20 +104,30 @@
"pnpm": {
"patchedDependencies": {
"dayjs": "patches/dayjs.patch"
}
},
"onlyBuiltDependencies": [
"@napi-rs/pinyin",
"@parcel/watcher",
"@swc/core",
"better-sqlite3",
"esbuild",
"sharp",
"simple-git-hooks",
"workerd"
]
},
"resolutions": {
"cross-spawn": ">=7.0.6",
"dayjs": "1.11.13",
"picomatch": "^4.0.2"
"picomatch": "^4.0.2",
"react": "^19",
"db0": "^0.3.1",
"vite": "^6"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
},
"lint-staged": {
"*": "eslint --fix"
},
"volta": {
"node": "22.12.0"
}
}
+1322 -1580
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -73,13 +73,13 @@ export class Cache {
export async function getCacheTable() {
try {
// 如果没有数据库,这里不会报错,只会在第一次访问的时候报错
const db = useDatabase()
logger.info("db: ", db.getInstance())
if (process.env.ENABLE_CACHE === "false") return
const cacheTable = new Cache(db)
if (process.env.INIT_TABLE !== "false") await cacheTable.init()
return cacheTable
} catch {
// logger.error("failed to init database ", e)
} catch (e) {
logger.error("failed to init database ", e)
}
}