/// // 打开设置界面时触发 async function onSettingWindowCreated(view: Element) { window.llonebot.log("setting window created"); let config = await window.llonebot.getConfig() function createHttpHostEleStr(host: string) { let eleStr = `

事件上报地址(http)

` return eleStr } function createWsHostEleStr(host: string) { let eleStr = `

事件上报地址(反向websocket)

` return eleStr } let httpHostsEleStr = "" for (const host of config.httpHosts) { httpHostsEleStr += createHttpHostEleStr(host); } let wsHostsEleStr = "" for (const host of config.wsHosts) { wsHostsEleStr += createWsHostEleStr(host); } let html = `
HTTP监听端口
${httpHostsEleStr}
正向Websocket监听端口 Access Token
${wsHostsEleStr}
启用HTTP支持
修改后须重启QQ生效
启用HTTP POST支持
修改后须重启QQ生效
启用正向Websocket支持
修改后须重启QQ生效
启用反向Websocket支持
修改后须重启QQ生效
上报文件进行base64编码
不开启时,上报文件将以本地路径形式发送
debug模式
开启后上报消息添加raw字段附带原始消息
上报自身消息
开启后上报自己发出的消息
日志
日志目录:${window.LiteLoader.plugins["LLOneBot"].path.data}
` const parser = new DOMParser(); const doc = parser.parseFromString(html, "text/html"); function addHostEle(type: string, initValue: string = "") { let addressEle, hostItemsEle; if (type === "ws") { let addressDoc = parser.parseFromString(createWsHostEleStr(initValue), "text/html"); addressEle = addressDoc.querySelector("setting-item") hostItemsEle = document.getElementById("wsHostItems"); } else { let addressDoc = parser.parseFromString(createHttpHostEleStr(initValue), "text/html"); addressEle = addressDoc.querySelector("setting-item") hostItemsEle = document.getElementById("httpHostItems"); } hostItemsEle.appendChild(addressEle); } doc.getElementById("addHttpHost").addEventListener("click", () => addHostEle("http")) doc.getElementById("addWsHost").addEventListener("click", () => addHostEle("ws")) function switchClick(eleId: string, configKey: string) { doc.getElementById(eleId)?.addEventListener("click", (e) => { const switchEle = e.target as HTMLInputElement if (config[configKey]) { config[configKey] = false switchEle.removeAttribute("is-active") } else { config[configKey] = true switchEle.setAttribute("is-active", "") } window.llonebot.setConfig(config) }) } switchClick("http", "enableHttp"); switchClick("httpPost", "enableHttpPost"); switchClick("websocket", "enableWs"); switchClick("websocketReverse", "enableWsReverse"); switchClick("debug", "debug"); switchClick("switchBase64", "enableBase64"); switchClick("reportSelfMessage", "reportSelfMessage"); switchClick("log", "log"); doc.getElementById("save")?.addEventListener("click", () => { const httpPortEle: HTMLInputElement = document.getElementById("httpPort") as HTMLInputElement; const httpHostEles: HTMLCollectionOf = document.getElementsByClassName("httpHost") as HTMLCollectionOf; const wsPortEle: HTMLInputElement = document.getElementById("wsPort") as HTMLInputElement; const wsHostEles: HTMLCollectionOf = document.getElementsByClassName("wsHost") as HTMLCollectionOf; const tokenEle = document.getElementById("token") as HTMLInputElement; // 获取端口和host const httpPort = httpPortEle.value let httpHosts: string[] = []; for (const hostEle of httpHostEles) { if (hostEle.value) { httpHosts.push(hostEle.value); } } const wsPort = wsPortEle.value const token = tokenEle.value let wsHosts: string[] = []; for (const hostEle of wsHostEles) { if (hostEle.value) { wsHosts.push(hostEle.value); } } config.httpPort = parseInt(httpPort); config.httpHosts = httpHosts; config.wsPort = parseInt(wsPort); config.wsHosts = wsHosts; config.token = token.trim(); window.llonebot.setConfig(config); alert("保存成功"); }) doc.body.childNodes.forEach(node => { view.appendChild(node); }); } export { onSettingWindowCreated }