From 569a475fef433b6438d13d466568be6992543a0b Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Mon, 27 Apr 2026 09:06:48 -0600 Subject: [PATCH] fix --- src/composables/maxkb.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/composables/maxkb.ts b/src/composables/maxkb.ts index cf579b8..368992c 100644 --- a/src/composables/maxkb.ts +++ b/src/composables/maxkb.ts @@ -2,6 +2,7 @@ import { ref } from "vue" import { getMaxkb, postMaxkb } from "../api" const enabled = ref(true) +let observer: MutationObserver | null = null function applyState() { document.querySelectorAll("body > [id^='maxkb-']").forEach(el => { @@ -9,6 +10,14 @@ function applyState() { }) } +function startObserver() { + if (observer) return + observer = new MutationObserver(() => { + if (!enabled.value) applyState() + }) + observer.observe(document.body, { childList: true }) +} + export async function fetchMaxkbState() { try { const res = await getMaxkb() @@ -26,5 +35,6 @@ export async function toggleMaxkb() { } export function initMaxkb() { + startObserver() fetchMaxkbState() }