fix: database created at userData path, not bundled in release

This commit is contained in:
2026-07-16 05:30:03 +08:00
parent 41f8842c1d
commit 0532963aca
2 changed files with 3 additions and 6 deletions
+3 -2
View File
@@ -1,4 +1,4 @@
import { BrowserWindow, ipcMain, dialog as dialogBox } from 'electron'
import { BrowserWindow, ipcMain, dialog as dialogBox, app } from 'electron'
import { captureScreen, closeScreenshot, getCapturedImage, getCapturedBase64, clearCapturedImage, startScreenshot } from './screenshot'
import { getMainWindow, openDialogWindow } from './window'
import * as fs from 'fs'
@@ -33,7 +33,8 @@ let db: any = null
function getDb() {
if (!db) {
const Database = require('better-sqlite3')
db = new Database('grading.db')
const dbPath = require('path').join(app.getPath('userData'), 'grading.db')
db = new Database(dbPath)
db.prepare(`CREATE TABLE IF NOT EXISTS history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
question_id INTEGER,
-4
View File
@@ -27,12 +27,8 @@
"files": [
"dist/**/*",
"dist-electron/**/*",
"database/**/*",
"package.json"
],
"extraResources": [
{ "from": "database/", "to": "database/" }
],
"win": {
"target": [
{