diff --git a/packages/geek-auto-start-chat-with-boss/runtime-file-utils.mjs b/packages/geek-auto-start-chat-with-boss/runtime-file-utils.mjs index 311a767..dcb31e2 100644 --- a/packages/geek-auto-start-chat-with-boss/runtime-file-utils.mjs +++ b/packages/geek-auto-start-chat-with-boss/runtime-file-utils.mjs @@ -141,3 +141,7 @@ export const writeStorageFile = async (fileName, content) => { fileContent ) } + +export const getPublicDbFilePath = () => { + return path.join(storageFilePath, 'public.db') +} \ No newline at end of file diff --git a/packages/run-core-of-geek-auto-start-chat-with-boss/main.mjs b/packages/run-core-of-geek-auto-start-chat-with-boss/main.mjs index 9e6d247..5462d07 100644 --- a/packages/run-core-of-geek-auto-start-chat-with-boss/main.mjs +++ b/packages/run-core-of-geek-auto-start-chat-with-boss/main.mjs @@ -8,7 +8,7 @@ import fs from 'node:fs' import path from 'node:path' import { get__dirname } from '@geekgeekrun/utils/legacy-path.mjs'; import JSON5 from 'json5' -import { readConfigFile, readStorageFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs' +import { readConfigFile, readStorageFile, getPublicDbFilePath } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs' import { sleep } from '@geekgeekrun/utils/sleep.mjs' import { AUTO_CHAT_ERROR_EXIT_CODE @@ -37,7 +37,7 @@ const { groupRobotAccessToken: dingTalkAccessToken } = readConfigFile('dingtalk. const initPlugins = (hooks) => { new DingtalkPlugin(dingTalkAccessToken).apply(hooks) - new SqlitePlugin().apply(hooks) + new SqlitePlugin(getPublicDbFilePath()).apply(hooks) } const main = async () => { diff --git a/packages/sqlite-plugin/src/index.ts b/packages/sqlite-plugin/src/index.ts index 5b3843f..816bc6f 100644 --- a/packages/sqlite-plugin/src/index.ts +++ b/packages/sqlite-plugin/src/index.ts @@ -12,13 +12,13 @@ import { BossActiveStatusRecord } from "./entity/BossActiveStatusRecord"; import { UserInfo } from "./entity/UserInfo"; import { parseCompanyScale, parseSalary } from "./utils/parser"; -async function initDb() { +async function initDb(dbFilePath) { const appDataSource = new DataSource({ type: "sqlite", synchronize: true, logging: true, logger: "simple-console", - database: "database.sqlite", + database: dbFilePath, entities: [ ChatStartupLog, BossInfo, @@ -37,8 +37,8 @@ async function initDb() { export default class SqlitePlugin { initPromise: Promise; - constructor() { - this.initPromise = initDb(); + constructor(dbFilePath) { + this.initPromise = initDb(dbFilePath); } userInfo = null diff --git a/packages/ui/src/main/flow/GEEK_AUTO_START_CHAT_WITH_BOSS_MAIN/index.ts b/packages/ui/src/main/flow/GEEK_AUTO_START_CHAT_WITH_BOSS_MAIN/index.ts index 1b44e74..4f67e78 100644 --- a/packages/ui/src/main/flow/GEEK_AUTO_START_CHAT_WITH_BOSS_MAIN/index.ts +++ b/packages/ui/src/main/flow/GEEK_AUTO_START_CHAT_WITH_BOSS_MAIN/index.ts @@ -1,7 +1,11 @@ import DingtalkPlugin from '@geekgeekrun/dingtalk-plugin/index.mjs' import { app } from 'electron' import { SyncHook, AsyncSeriesHook } from 'tapable' -import { readConfigFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs' +import { + readConfigFile, + getPublicDbFilePath +} from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs' + import * as fs from 'fs' import { pipeWriteRegardlessError } from '../utils/pipe' import { getAnyAvailablePuppeteerExecutable } from '../CHECK_AND_DOWNLOAD_DEPENDENCIES/utils/puppeteer-executable' @@ -15,7 +19,7 @@ const { groupRobotAccessToken: dingTalkAccessToken } = readConfigFile('dingtalk. const initPlugins = (hooks) => { new DingtalkPlugin(dingTalkAccessToken).apply(hooks) - new SqlitePlugin().apply(hooks) + new SqlitePlugin(getPublicDbFilePath()).apply(hooks) } let isParentProcessDisconnect = false