From 8d5c7369753d179f38a316df288cf806acc2a203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 5 May 2024 13:36:53 +0800 Subject: [PATCH] fix: webui-6 --- static/components/NapCat.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/static/components/NapCat.ts b/static/components/NapCat.ts index 84c387fd..d047e095 100644 --- a/static/components/NapCat.ts +++ b/static/components/NapCat.ts @@ -212,10 +212,13 @@ function aprilFoolsEgg(node: Element) { const errMsg = await window.llonebot.getError() if (!errMsg) { + //@ts-ignore 等待修复 errDom.classList.remove('show') } else { + //@ts-ignore 等待修复 errDom.classList.add('show') } + //@ts-ignore 等待修复 errCodeDom.innerHTML = errMsg } showError().then() @@ -281,8 +284,8 @@ function aprilFoolsEgg(node: Element) { ob11Config[type].push(''); } const initReverseHost = (type: string, doc: Document = document) => { - const hostContainerDom = doc.body.querySelector(`#config-ob11-${type}-list`) - ;[...hostContainerDom.childNodes].forEach((dom) => dom.remove()) + const hostContainerDom = doc.body?.querySelector(`#config-ob11-${type}-list`); + [...hostContainerDom.childNodes].forEach((dom) => dom.remove()); buildHostList(ob11Config[type], type).forEach((dom) => { hostContainerDom?.appendChild(dom); }) @@ -313,13 +316,14 @@ function aprilFoolsEgg(node: Element) { doc.querySelectorAll('setting-switch[data-config-key]').forEach((dom: Element) => { dom.addEventListener('click', () => { const active = dom.getAttribute('is-active') === undefined - + //@ts-ignore 等待修复 setConfig(dom.dataset.configKey, active) if (active) dom.setAttribute('is-active', '') else dom.removeAttribute('is-active') - + //@ts-ignore 等待修复 if (!isEmpty(dom.dataset.controlDisplayId)) { + //@ts-ignore 等待修复 const displayDom = document.querySelector(`#${dom.dataset.controlDisplayId}`) if (active) displayDom?.removeAttribute('is-hidden') else displayDom?.setAttribute('is-hidden', '') @@ -333,6 +337,7 @@ function aprilFoolsEgg(node: Element) { .forEach((dom: Element) => { dom.addEventListener('input', () => { const Type = dom.getAttribute('type') + //@ts-ignore 等待修复 const configKey = dom.dataset.configKey const configValue = Type === 'number' ? (parseInt((dom as HTMLInputElement).value) >= 1 ? parseInt((dom as HTMLInputElement).value) : 1) : (dom as HTMLInputElement).value @@ -342,7 +347,8 @@ function aprilFoolsEgg(node: Element) { // 下拉框 doc.querySelectorAll('ob-setting-select[data-config-key]').forEach((dom: Element) => { - dom.addEventListener('selected', (e: CustomEvent) => { + dom?.addEventListener('selected', (e: CustomEvent) => { + //@ts-ignore 等待修复 const configKey = dom.dataset.configKey const configValue = e.detail.value @@ -364,6 +370,7 @@ function aprilFoolsEgg(node: Element) { view.appendChild(node) }) // 更新逻辑 + //@ts-ignore 等待修复 async function checkVersionFunc(ResultVersion: CheckVersion) { const titleDom = view.querySelector('#llonebot-update-title')! const buttonDom = view.querySelector('#llonebot-update-button')! @@ -411,4 +418,5 @@ function aprilFoolsEgg(node: Element) { window.llonebot.setConfig(true, config) }) } - export { onSettingWindowCreated } \ No newline at end of file +} +export { onSettingWindowCreated } \ No newline at end of file