diff --git a/src/common/config.ts b/src/common/config.ts index 8829fa7..de9e0cb 100644 --- a/src/common/config.ts +++ b/src/common/config.ts @@ -35,6 +35,7 @@ export class ConfigUtil { ob11: ob11Default, heartInterval: 60000, token: "", + messagePostFormat: "array", enableLocalFile2Url: false, debug: false, log: false, diff --git a/src/common/types.ts b/src/common/types.ts index 0cc5a35..11aa8b1 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -13,6 +13,7 @@ export interface Config { ob11: OB11Config token?: string heartInterval?: number // ms + messagePostFormat?: 'array' | 'string' enableLocalFile2Url?: boolean // 开启后,本地文件路径图片会转成http链接, 语音会转成base64 debug?: boolean reportSelfMessage?: boolean diff --git a/src/global.d.ts b/src/global.d.ts index 000cd50..02e92a8 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -7,4 +7,11 @@ declare global { llonebot: typeof llonebot; LiteLoader: any; } + + interface Event { + detail?: { + name: string; + value: string; + } + } } \ No newline at end of file diff --git a/src/renderer.ts b/src/renderer.ts index 36e9f0a..38e1e01 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -4,6 +4,7 @@ // 打开设置界面时触发 async function onSettingWindowCreated(view: Element) { window.llonebot.log("setting window created"); + const isEmpty = (value: any) => value === undefined || value === null || value === ''; let config = await window.llonebot.getConfig() const httpClass = "http"; const httpPostClass = "http-post"; @@ -106,6 +107,16 @@ async function onSettingWindowCreated(view: Element) { + +
+ 消息上报数据类型 + 如客户端无特殊需求推荐保持默认设置,两者的详细差异可参考 OneBot v11 文档 +
+ + Array + String + +
上报文件不采用本地路径
@@ -174,6 +185,11 @@ async function onSettingWindowCreated(view: Element) { doc.getElementById("addHttpHost").addEventListener("click", () => addHostEle("http")) doc.getElementById("addWsHost").addEventListener("click", () => addHostEle("ws")) + doc.getElementById("messagePostFormat").addEventListener("selected", (e) => { + const _config = config || {}; + _config.messagePostFormat = e.detail && !isEmpty(e.detail.value) ? e.detail.value : 'array'; + window.llonebot.setConfig(_config); + }) function switchClick(eleId: string, configKey: string, _config=null) { if (!_config){