From 4d8edd5da90a959377fb1838ee6074da9fa19ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Wed, 8 May 2024 21:29:40 +0800 Subject: [PATCH] fix:webui config some value --- src/webui/src/api/OB11Config.ts | 6 ++++-- src/webui/ui/NapCat.ts | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/webui/src/api/OB11Config.ts b/src/webui/src/api/OB11Config.ts index 5c69f90a..94fb8f94 100644 --- a/src/webui/src/api/OB11Config.ts +++ b/src/webui/src/api/OB11Config.ts @@ -51,14 +51,16 @@ export const OB11SetConfigHandler: RequestHandler = async (req, res) => { }); return; } - let configFilePath = resolve(__dirname, `./config/onebot_${await DataRuntime.getQQLoginUin()}.json`); + let configFilePath = resolve(__dirname, `./config/onebot11_${await DataRuntime.getQQLoginUin()}.json`); try { JSON.parse(req.body.config) readFileSync(configFilePath); } catch (e) { - configFilePath = resolve(__dirname, `./config/onebot.json`); + //console.log(e); + configFilePath = resolve(__dirname, `./config/onebot11.json`); } + //console.log(configFilePath,JSON.parse(req.body.config)); writeFileSync(configFilePath, JSON.stringify(JSON.parse(req.body.config), null, 4)); res.send({ code: 0, diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index 90eac717..4c9e1e11 100644 --- a/src/webui/ui/NapCat.ts +++ b/src/webui/ui/NapCat.ts @@ -106,12 +106,12 @@ async function onSettingWindowCreated(view: Element) { SettingItem( ' WebSocket 服务心跳间隔', '控制每隔多久发送一个心跳包,单位为毫秒', - `
`, + `
`, ), SettingItem( 'Access token', undefined, - `
`, + `
`, ), SettingItem( '新消息上报格式', @@ -128,8 +128,8 @@ async function onSettingWindowCreated(view: Element) { SettingItem( '音乐卡片签名地址', undefined, - `
`, - 'config-musicSignUrl', + `
`, + 'ob11.musicSignUrl', ), SettingItem('', undefined, SettingButton('保存', 'config-ob11-save', 'primary')), ]), @@ -137,7 +137,7 @@ async function onSettingWindowCreated(view: Element) { SettingItem( '上报 Bot 自身发送的消息', '上报 event 为 message_sent', - SettingSwitch('reportSelfMessage', ob11Config.reportSelfMessage), + SettingSwitch('ob11.reportSelfMessage', ob11Config.reportSelfMessage), ) ]), SettingList([ @@ -213,10 +213,12 @@ async function onSettingWindowCreated(view: Element) { } const initReverseHost = (type: string, doc: Document = document) => { const hostContainerDom = doc.body?.querySelector(`#config-ob11-${type}-list`); - /*[...hostContainerDom.childNodes].forEach((dom) => dom.remove()); - buildHostList(ob11Config[type], type).forEach((dom) => { - hostContainerDom?.appendChild(dom); - })*/ + if (hostContainerDom) { + [...hostContainerDom.childNodes].forEach((dom) => dom.remove()); + buildHostList(ob11Config[type], type).forEach((dom) => { + hostContainerDom?.appendChild(dom); + }) + } } initReverseHost('httpHosts', doc); initReverseHost('wsHosts', doc);