mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
feat: Add setting section of messagePostFormat
This commit is contained in:
parent
66de0076d4
commit
ffdec86209
@ -35,6 +35,7 @@ export class ConfigUtil {
|
|||||||
ob11: ob11Default,
|
ob11: ob11Default,
|
||||||
heartInterval: 60000,
|
heartInterval: 60000,
|
||||||
token: "",
|
token: "",
|
||||||
|
messagePostFormat: "array",
|
||||||
enableLocalFile2Url: false,
|
enableLocalFile2Url: false,
|
||||||
debug: false,
|
debug: false,
|
||||||
log: false,
|
log: false,
|
||||||
|
@ -13,6 +13,7 @@ export interface Config {
|
|||||||
ob11: OB11Config
|
ob11: OB11Config
|
||||||
token?: string
|
token?: string
|
||||||
heartInterval?: number // ms
|
heartInterval?: number // ms
|
||||||
|
messagePostFormat?: 'array' | 'string'
|
||||||
enableLocalFile2Url?: boolean // 开启后,本地文件路径图片会转成http链接, 语音会转成base64
|
enableLocalFile2Url?: boolean // 开启后,本地文件路径图片会转成http链接, 语音会转成base64
|
||||||
debug?: boolean
|
debug?: boolean
|
||||||
reportSelfMessage?: boolean
|
reportSelfMessage?: boolean
|
||||||
|
7
src/global.d.ts
vendored
7
src/global.d.ts
vendored
@ -7,4 +7,11 @@ declare global {
|
|||||||
llonebot: typeof llonebot;
|
llonebot: typeof llonebot;
|
||||||
LiteLoader: any;
|
LiteLoader: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Event {
|
||||||
|
detail?: {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,6 +4,7 @@
|
|||||||
// 打开设置界面时触发
|
// 打开设置界面时触发
|
||||||
async function onSettingWindowCreated(view: Element) {
|
async function onSettingWindowCreated(view: Element) {
|
||||||
window.llonebot.log("setting window created");
|
window.llonebot.log("setting window created");
|
||||||
|
const isEmpty = (value: any) => value === undefined || value === null || value === '';
|
||||||
let config = await window.llonebot.getConfig()
|
let config = await window.llonebot.getConfig()
|
||||||
const httpClass = "http";
|
const httpClass = "http";
|
||||||
const httpPostClass = "http-post";
|
const httpPostClass = "http-post";
|
||||||
@ -106,6 +107,16 @@ async function onSettingWindowCreated(view: Element) {
|
|||||||
</setting-list>
|
</setting-list>
|
||||||
</setting-panel>
|
</setting-panel>
|
||||||
<setting-panel>
|
<setting-panel>
|
||||||
|
<setting-item data-direction="row" class="hostItem vertical-list-item">
|
||||||
|
<div>
|
||||||
|
<setting-text>消息上报数据类型</setting-text>
|
||||||
|
<setting-text data-type="secondary">如客户端无特殊需求推荐保持默认设置,两者的详细差异可参考 <a href="javascript:LiteLoader.api.openExternal('https://github.com/botuniverse/onebot-11/tree/master/message#readme');">OneBot v11 文档</a></setting-text>
|
||||||
|
</div>
|
||||||
|
<setting-select id="messagePostFormat">
|
||||||
|
<setting-option data-value="array" ${config.messagePostFormat !== "string" ? "is-selected" : ""}>Array</setting-option>
|
||||||
|
<setting-option data-value="string" ${config.messagePostFormat === "string" ? "is-selected" : ""}>String</setting-option>
|
||||||
|
</setting-select>
|
||||||
|
</setting-item>
|
||||||
<setting-item data-direction="row" class="hostItem vertical-list-item">
|
<setting-item data-direction="row" class="hostItem vertical-list-item">
|
||||||
<div>
|
<div>
|
||||||
<div>上报文件不采用本地路径</div>
|
<div>上报文件不采用本地路径</div>
|
||||||
@ -174,6 +185,11 @@ async function onSettingWindowCreated(view: Element) {
|
|||||||
|
|
||||||
doc.getElementById("addHttpHost").addEventListener("click", () => addHostEle("http"))
|
doc.getElementById("addHttpHost").addEventListener("click", () => addHostEle("http"))
|
||||||
doc.getElementById("addWsHost").addEventListener("click", () => addHostEle("ws"))
|
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) {
|
function switchClick(eleId: string, configKey: string, _config=null) {
|
||||||
if (!_config){
|
if (!_config){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user