diff --git a/src/common/config.ts b/src/common/config.ts index f7ec98e..abfab1b 100644 --- a/src/common/config.ts +++ b/src/common/config.ts @@ -44,6 +44,7 @@ export class ConfigUtil { token: '' } const defaultConfig: Config = { + enableLLOB: true, satori: satoriDefault, ob11: ob11Default, heartInterval: 60000, diff --git a/src/common/types.ts b/src/common/types.ts index 14d780e..d1b1a48 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -28,6 +28,7 @@ export interface SatoriConfig { } export interface Config { + enableLLOB: boolean satori: SatoriConfig ob11: OB11Config token?: string @@ -49,8 +50,6 @@ export interface Config { /** @deprecated */ wsPort?: string /** @deprecated */ - enableLLOB?: boolean - /** @deprecated */ reportSelfMessage?: boolean } diff --git a/src/main/main.ts b/src/main/main.ts index 356b81d..35619ee 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -182,6 +182,15 @@ function onLoad() { log('process pid', process.pid) const config = getConfigUtil().getConfig() + + if (config.enableLLOB && (config.satori.enable || config.ob11.enable)) { + startHook() + } else { + llonebotError.otherError = 'LLOneBot 未启动' + log('LLOneBot 开关设置为关闭,不启动 LLOneBot') + return + } + ctx.plugin(Log, { enable: config.log!, filename: logFileName @@ -224,7 +233,6 @@ function onBrowserWindowCreated(window: BrowserWindow) { try { onLoad() - startHook() } catch (e) { console.log(e) } diff --git a/src/ntqqapi/core.ts b/src/ntqqapi/core.ts index 347e07f..21d760c 100644 --- a/src/ntqqapi/core.ts +++ b/src/ntqqapi/core.ts @@ -47,11 +47,6 @@ class Core extends Service { } public start() { - if (!this.config.ob11.enable && !this.config.satori.enable) { - llonebotError.otherError = 'LLOneBot 未启动' - this.ctx.logger.info('LLOneBot 开关设置为关闭,不启动 LLOneBot') - return - } this.startTime = Date.now() this.registerListener() this.ctx.logger.info(`LLOneBot/${version}`) diff --git a/src/renderer/index.ts b/src/renderer/index.ts index ad11311..22fc53b 100644 --- a/src/renderer/index.ts +++ b/src/renderer/index.ts @@ -43,6 +43,13 @@ async function onSettingWindowCreated(view: Element) { SettingButton('请稍候', 'llonebot-update-button', 'secondary'), ), ]), + SettingList([ + SettingItem( + '是否启用 LLOneBot,重启 QQ 后生效', + null, + SettingSwitch('enableLLOB', config.enableLLOB, { 'control-display-id': 'config-enableLLOB' }), + ) + ]), SettingList([ SettingItem( '是否启用 Satori 协议',