feat: Made select works

This commit is contained in:
Misa Liu 2024-03-04 22:28:38 +08:00
parent cbb732c778
commit afacc79b56
No known key found for this signature in database
GPG Key ID: F70B23D0A4FED791

View File

@ -61,6 +61,14 @@ async function onSettingWindowCreated(view: Element) {
SettingItem('Access token', null,
`<div class="q-input" style="width:210px;"><input class="q-input__inner" data-config-key="token" type="text" value="${config.token}" placeholder="未设置" /></div>`,
),
SettingItem(
'消息上报格式类型',
'如客户端无特殊需求推荐保持默认设置,两者的详细差异可参考 <a href="javascript:LiteLoader.api.openExternal(\'https://github.com/botuniverse/onebot-11/tree/master/message#readme\');">OneBot v11 文档</a>',
SettingSelect([
{ text: '消息段', value: 'array' },
{ text: 'CQ码', value: 'string' },
], 'ob11.messagePostFormat', config.ob11.messagePostFormat),
),
SettingItem(
'ffmpeg 路径', `${!isEmpty(config.ffmpeg) ? config.ffmpeg : '未指定'}`,
SettingButton('选择', 'config-ffmpeg-select'),
@ -72,14 +80,6 @@ async function onSettingWindowCreated(view: Element) {
)
]),
SettingList([
SettingItem(
'消息上报格式类型',
'如客户端无特殊需求推荐保持默认设置,两者的详细差异可参考 <a href="javascript:LiteLoader.api.openExternal(\'https://github.com/botuniverse/onebot-11/tree/master/message#readme\');">OneBot v11 文档</a>',
SettingSelect([
{ text: '消息段', value: 'array' },
{ text: 'CQ码', value: 'string' },
], 'ob11.messagePostFormat', config.ob11.messagePostFormat),
),
SettingItem(
'使用 Base64 编码获取文件',
'开启后,调用 /get_image、/get_record 时,获取不到 url 时添加一个 Base64 字段',
@ -149,6 +149,16 @@ async function onSettingWindowCreated(view: Element) {
});
});
// 下拉框
doc.querySelectorAll('setting-select').forEach((dom: HTMLElement) => {
dom.addEventListener('selected', (e: CustomEvent) => {
const configKey = dom.dataset.configKey;
const configValue = e.detail.value;
setConfig(configKey, configValue);
});
});
doc.body.childNodes.forEach(node => {
view.appendChild(node);
});