This commit is contained in:
chenqiang 2025-08-27 08:55:57 +08:00
parent 42c5fbcb70
commit d88eabe3ac
3 changed files with 1408 additions and 217 deletions

1563
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -8,17 +8,21 @@
"electron:build": "vue-cli-service electron:build",
"electron:serve": "vue-cli-service electron:serve",
"postinstall": "electron-builder install-app-deps",
"postuninstall": "electron-builder install-app-deps"
"postuninstall": "electron-builder install-app-deps",
"rebuild-deps": "electron-builder install-app-deps",
"rebuild-sqlite3": "npm_config_runtime=electron npm_config_target=11.5.0 npm_config_disturl=https://electronjs.org/headers npm_config_build_from_source=true node-pre-gyp rebuild --target=11.5.0 --runtime=electron --fallback-to-build --directory=./node_modules/sqlite3/ --dist-url=https://electronjs.org/headers"
},
"main": "background.js",
"dependencies": {
"argon2": "^0.27.2",
"argon2": "^0.25.1",
"core-js": "^3.6.5",
"sqlite3": "^4.2.0",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
},
"devDependencies": {
"@electron/rebuild": "^3.2.13",
"@vue/cli-plugin-babel": "^4.5.19",
"@vue/cli-plugin-router": "~4.5.17",
"@vue/cli-plugin-vuex": "~4.5.17",

View File

@ -52,6 +52,10 @@ app.on('activate', () => {
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
// 在文件顶部添加
const sqlite3 = require('sqlite3').verbose();
// 在app.on('ready')事件中添加
app.on('ready', async () => {
if (isDevelopment && !process.env.IS_TEST) {
// Install Vue Devtools
@ -61,8 +65,54 @@ app.on('ready', async () => {
console.error('Vue Devtools failed to install:', e.toString())
}
}
createWindow()
})
// 测试SQLite连接
try {
console.log('尝试连接SQLite...');
const db = new sqlite3.Database(':memory:', (err) => {
if (err) {
console.error('SQLite连接失败:', err.message);
} else {
console.log('SQLite连接成功!');
// 执行简单的SQL操作
db.serialize(() => {
console.log('创建测试表...');
db.run('CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, name TEXT)', (err) => {
if (err) {
console.error('创建表失败:', err.message);
} else {
console.log('表创建成功');
// 插入测试数据
db.run('INSERT INTO test (name) VALUES (?)', ['测试数据'], function(err) {
if (err) {
console.error('插入数据失败:', err.message);
} else {
console.log('数据插入成功ID:', this.lastID);
// 查询数据
db.all('SELECT * FROM test', [], (err, rows) => {
if (err) {
console.error('查询失败:', err.message);
} else {
console.log('查询结果:', rows);
}
db.close();
});
}
});
}
});
});
}
});
} catch (error) {
console.error('SQLite测试异常:', error);
}
createWindow();
});
// Exit cleanly on request from parent process in development mode.
if (isDevelopment) {