diff --git a/src/renderer/index.ts b/src/renderer/index.ts index 2329bce..a69f13a 100644 --- a/src/renderer/index.ts +++ b/src/renderer/index.ts @@ -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');