change sqlite backend; upgrade electron; fix ipc file cannot listen in macOS

This commit is contained in:
geekgeekrun
2026-01-21 02:56:42 +08:00
parent c23d590052
commit afe8a820c1
7 changed files with 494 additions and 587 deletions

View File

@@ -38,18 +38,9 @@ if (!ipcSocketName) {
process.env.GEEKGEEKRUND_PIPE_NAME = `geekgeekrun-d_${randomUUID()}`
ipcSocketName = process.env.GEEKGEEKRUND_PIPE_NAME
}
let ipcSocketPath
if (process.platform === 'win32') {
ipcSocketPath = `\\\\.\\pipe\\${ipcSocketName}`
}
else {
ipcSocketPath = path.join(tmpdir(), `${ipcSocketName}.sock`)
if (process.platform === 'darwin' && !fs.existsSync(ipcSocketPath)) {
fs.writeFileSync(ipcSocketPath, '')
// 设置权限Unix
fs.chmodSync(ipcSocketPath, 0o777)
}
}
const ipcSocketPath = process.platform === 'win32'
? `\\\\.\\pipe\\${ipcSocketName}`
: path.join(tmpdir(), `${ipcSocketName}.sock`)
const workers = new Map(); // workerId -> { process, status, restartCount, socket, latestScreenshot, latestScreenshotAt }
const guiClients = new Set(); // GUI客户端连接集合

View File

@@ -7,8 +7,8 @@
"cli-highlight": "^2.1.11",
"lodash": "^4.17.21",
"reflect-metadata": "^0.2.1",
"sqlite3": "5.1.6",
"typeorm": "0.3.11"
"better-sqlite3": "12.6.2",
"typeorm": "0.3.28"
},
"devDependencies": {
"@types/lodash": "^4.17.23",

View File

@@ -21,7 +21,6 @@ import { ChatMessageRecord } from './entity/ChatMessageRecord'
import { LlmModelUsageRecord } from './entity/LlmModelUsageRecord'
import { JobHireStatusRecord } from './entity/JobHireStatusRecord'
import sqlite3 from 'sqlite3';
import {
saveChatStartupRecord,
saveJobInfoFromRecommendPage,
@@ -45,12 +44,11 @@ import * as typeorm from 'typeorm'
export function initDb(dbFilePath) {
const { DataSource } = typeorm
const appDataSource = new DataSource({
type: "sqlite",
type: "better-sqlite3",
synchronize: false,
logging: true,
logger: "simple-console",
database: dbFilePath,
driver: sqlite3, // The important line
entities: [
ChatStartupLog,
BossInfo,

View File

@@ -48,10 +48,10 @@
"@electron-toolkit/eslint-config": "^1.0.2",
"@electron-toolkit/eslint-config-ts": "^1.0.1",
"@electron-toolkit/tsconfig": "^1.0.1",
"@inquirer/prompts": "^7.0.1",
"@inquirer/select": "^4.0.1",
"@geekgeekrun/dingtalk-plugin": "workspace:*",
"@geekgeekrun/geek-auto-start-chat-with-boss": "workspace:*",
"@inquirer/prompts": "^7.0.1",
"@inquirer/select": "^4.0.1",
"@puppeteer/browsers": "^2.11.0",
"@rushstack/eslint-patch": "^1.7.1",
"@types/lodash": "^4.17.23",
@@ -64,7 +64,7 @@
"@vue/eslint-config-typescript": "^12.0.0",
"animate.css": "^4.1.1",
"cross-env": "^7.0.3",
"electron": "28.2.0",
"electron": "39.2.7",
"electron-builder": "^24.9.1",
"electron-vite": "^2.0.0",
"element-plus": "^2.8.4",
@@ -87,4 +87,4 @@
"vue-router": "^4.2.5",
"vue-tsc": "^1.8.27"
}
}
}

View File

@@ -19,13 +19,8 @@ export async function connectToDaemon() {
await new Promise((resolve, reject) => {
const ipcSocketName = process.env.GEEKGEEKRUND_PIPE_NAME
const ipcSocketPath = process.platform === 'win32'
? `\\\\.\\pipe\\${ipcSocketName}`
: path.join(tmpdir(), `${ipcSocketName}.sock`)
if (process.platform === 'darwin' && !fs.existsSync(ipcSocketPath)) {
fs.writeFileSync(ipcSocketPath, '')
// 设置权限Unix
fs.chmodSync(ipcSocketPath, 0o777)
}
? `\\\\.\\pipe\\${ipcSocketName}`
: path.join(tmpdir(), `${ipcSocketName}.sock`)
daemonClient.connect(ipcSocketPath, 'localhost', () => {
isConnected = true
console.log('已连接到守护进程');

View File

@@ -20,7 +20,7 @@ export const initDbWorker = () => {
// attach more event
worker?.off('message', handler)
} else if (data.type === 'DB_INIT_FAIL') {
reject(undefined)
reject(data.error)
worker?.terminate()
worker?.off('message', handler)
worker = null

1039
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff