mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
refactor
This commit is contained in:
parent
364dfe8b93
commit
5b90a25f8f
@ -44,6 +44,7 @@ export class ConfigUtil {
|
|||||||
token: ''
|
token: ''
|
||||||
}
|
}
|
||||||
const defaultConfig: Config = {
|
const defaultConfig: Config = {
|
||||||
|
enableLLOB: true,
|
||||||
satori: satoriDefault,
|
satori: satoriDefault,
|
||||||
ob11: ob11Default,
|
ob11: ob11Default,
|
||||||
heartInterval: 60000,
|
heartInterval: 60000,
|
||||||
|
@ -28,6 +28,7 @@ export interface SatoriConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
|
enableLLOB: boolean
|
||||||
satori: SatoriConfig
|
satori: SatoriConfig
|
||||||
ob11: OB11Config
|
ob11: OB11Config
|
||||||
token?: string
|
token?: string
|
||||||
@ -49,8 +50,6 @@ export interface Config {
|
|||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
wsPort?: string
|
wsPort?: string
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
enableLLOB?: boolean
|
|
||||||
/** @deprecated */
|
|
||||||
reportSelfMessage?: boolean
|
reportSelfMessage?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,6 +182,15 @@ function onLoad() {
|
|||||||
log('process pid', process.pid)
|
log('process pid', process.pid)
|
||||||
|
|
||||||
const config = getConfigUtil().getConfig()
|
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, {
|
ctx.plugin(Log, {
|
||||||
enable: config.log!,
|
enable: config.log!,
|
||||||
filename: logFileName
|
filename: logFileName
|
||||||
@ -224,7 +233,6 @@ function onBrowserWindowCreated(window: BrowserWindow) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
onLoad()
|
onLoad()
|
||||||
startHook()
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
|
@ -47,11 +47,6 @@ class Core extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public start() {
|
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.startTime = Date.now()
|
||||||
this.registerListener()
|
this.registerListener()
|
||||||
this.ctx.logger.info(`LLOneBot/${version}`)
|
this.ctx.logger.info(`LLOneBot/${version}`)
|
||||||
|
@ -43,6 +43,13 @@ async function onSettingWindowCreated(view: Element) {
|
|||||||
SettingButton('请稍候', 'llonebot-update-button', 'secondary'),
|
SettingButton('请稍候', 'llonebot-update-button', 'secondary'),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
|
SettingList([
|
||||||
|
SettingItem(
|
||||||
|
'是否启用 LLOneBot,重启 QQ 后生效',
|
||||||
|
null,
|
||||||
|
SettingSwitch('enableLLOB', config.enableLLOB, { 'control-display-id': 'config-enableLLOB' }),
|
||||||
|
)
|
||||||
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
SettingItem(
|
SettingItem(
|
||||||
'是否启用 Satori 协议',
|
'是否启用 Satori 协议',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user