From aafd8b6bf77a3e8fc1ae6dc202aa83caa46ed4fa Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Wed, 22 Oct 2025 09:11:15 +0900 Subject: fix(frontend): ダークモードの同期が機能しない場合がある問題を修正 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #16688 --- packages/frontend/src/boot/common.ts | 10 +--------- packages/frontend/src/theme.ts | 7 +++---- 2 files changed, 4 insertions(+), 13 deletions(-) (limited to 'packages') diff --git a/packages/frontend/src/boot/common.ts b/packages/frontend/src/boot/common.ts index 4becf32ab5..95ba278ff4 100644 --- a/packages/frontend/src/boot/common.ts +++ b/packages/frontend/src/boot/common.ts @@ -176,7 +176,7 @@ export async function common(createVue: () => Promise>) { })(); applyTheme(theme); - }, { immediate: isSafeMode || miLocalStorage.getItem('theme') == null }); + }, { immediate: true }); window.document.documentElement.dataset.colorScheme = store.s.darkMode ? 'dark' : 'light'; @@ -195,14 +195,6 @@ export async function common(createVue: () => Promise>) { applyTheme(theme ?? defaultLightTheme); } }); - } - - if (!isSafeMode) { - if (prefer.s.darkTheme && store.s.darkMode) { - if (miLocalStorage.getItem('themeId') !== prefer.s.darkTheme.id) applyTheme(prefer.s.darkTheme); - } else if (prefer.s.lightTheme && !store.s.darkMode) { - if (miLocalStorage.getItem('themeId') !== prefer.s.lightTheme.id) applyTheme(prefer.s.lightTheme); - } fetchInstanceMetaPromise.then(() => { // TODO: instance.defaultLightTheme/instance.defaultDarkThemeが不正な形式だった場合のケア diff --git a/packages/frontend/src/theme.ts b/packages/frontend/src/theme.ts index 4d03b1d0e9..7cbaf87243 100644 --- a/packages/frontend/src/theme.ts +++ b/packages/frontend/src/theme.ts @@ -131,7 +131,7 @@ function applyThemeInternal(theme: Theme, persist: boolean) { } let timeout: number | null = null; -let currentTheme: Theme | null = null; +let currentThemeId = miLocalStorage.getItem('themeId'); export function applyTheme(theme: Theme, persist = true) { if (timeout) { @@ -139,9 +139,8 @@ export function applyTheme(theme: Theme, persist = true) { timeout = null; } - if (deepEqual(currentTheme, theme)) return; - // リアクティビティ解除 - currentTheme = deepClone(theme); + if (theme.id === currentThemeId) return; + currentThemeId = theme.id; if (window.document.startViewTransition != null) { window.document.documentElement.classList.add('_themeChanging_'); -- cgit v1.2.3-freya