fix: database created at userData path, not bundled in release
This commit is contained in:
@@ -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 { captureScreen, closeScreenshot, getCapturedImage, getCapturedBase64, clearCapturedImage, startScreenshot } from './screenshot'
|
||||||
import { getMainWindow, openDialogWindow } from './window'
|
import { getMainWindow, openDialogWindow } from './window'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
@@ -33,7 +33,8 @@ let db: any = null
|
|||||||
function getDb() {
|
function getDb() {
|
||||||
if (!db) {
|
if (!db) {
|
||||||
const Database = require('better-sqlite3')
|
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 (
|
db.prepare(`CREATE TABLE IF NOT EXISTS history (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
question_id INTEGER,
|
question_id INTEGER,
|
||||||
|
|||||||
@@ -27,12 +27,8 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"dist/**/*",
|
"dist/**/*",
|
||||||
"dist-electron/**/*",
|
"dist-electron/**/*",
|
||||||
"database/**/*",
|
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
"extraResources": [
|
|
||||||
{ "from": "database/", "to": "database/" }
|
|
||||||
],
|
|
||||||
"win": {
|
"win": {
|
||||||
"target": [
|
"target": [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user