From c4279acdae78fc178685bda21ff5458eee9ac256 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Apr 2026 13:56:41 +0000 Subject: [PATCH] fix: address code review feedback for background feature - Use SETTINGS_CHANGED_EVENT constant to prevent typos - Enforce 2MB image size limit (block upload instead of warn) - Fix resetAll to force re-render SettingItem for enabled toggle - Optimize watchSettings callback to only reload on relevant key changes Agent-Logs-Url: https://github.com/ZeroCatDev/Classworks/sessions/6dfae4c0-df49-4612-88b8-9e31287538b0 Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com> --- src/App.vue | 11 +++++++---- .../settings/cards/BackgroundSettingsCard.vue | 8 ++++++-- src/utils/settings.js | 17 ++++++++++------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/App.vue b/src/App.vue index 1771bc8..56d4c98 100644 --- a/src/App.vue +++ b/src/App.vue @@ -67,10 +67,13 @@ onMounted(() => { loadBgSettings(); - unwatchSettings = watchSettings(() => { - loadBgSettings(); - // Reapply theme on settings change too - theme.global.name.value = getSetting("theme.mode"); + unwatchSettings = watchSettings((_, event) => { + // If event detail is available (same-tab change), only reload on background keys + const changedKey = event?.detail?.key; + if (!changedKey || changedKey.startsWith("background.") || changedKey === "theme.mode") { + loadBgSettings(); + theme.global.name.value = getSetting("theme.mode"); + } }); window.addEventListener('beforeinstallprompt', (e) => { diff --git a/src/components/settings/cards/BackgroundSettingsCard.vue b/src/components/settings/cards/BackgroundSettingsCard.vue index d6d0ab7..d011b50 100644 --- a/src/components/settings/cards/BackgroundSettingsCard.vue +++ b/src/components/settings/cards/BackgroundSettingsCard.vue @@ -1,7 +1,7 @@