mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
feat: Write config
This commit is contained in:
parent
9acb0665d8
commit
a5877fec17
@ -13,7 +13,17 @@ import StyleRaw from './style.css?raw';
|
||||
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()
|
||||
let config = await window.llonebot.getConfig();
|
||||
const setConfig = (key: string, value: any) => {
|
||||
const configKey = key.split('.');
|
||||
|
||||
if (configKey.length === 2) config[configKey[0]][configKey[1]] = value;
|
||||
else config[key] = value;
|
||||
|
||||
if (key.indexOf('ob11') === -1) window.llonebot.setConfig(config);
|
||||
|
||||
console.log(config);
|
||||
};
|
||||
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString([
|
||||
@ -112,6 +122,8 @@ async function onSettingWindowCreated(view: Element) {
|
||||
dom.addEventListener('click', () => {
|
||||
const active = dom.getAttribute('is-active') === null;
|
||||
|
||||
setConfig(dom.dataset.configKey, active);
|
||||
|
||||
if (active) dom.setAttribute('is-active', '');
|
||||
else dom.removeAttribute('is-active');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user