From a7abf73e432caa6b06b868e7c8c01c6f31b6cc54 Mon Sep 17 00:00:00 2001 From: WT <24277775+zam157@users.noreply.github.com> Date: Thu, 27 Oct 2022 21:02:16 +0800 Subject: [PATCH] fix(theme): use stored preference to be the value of `userPreference` (#1543) Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> --- .../theme-default/components/VPSwitchAppearance.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/theme-default/components/VPSwitchAppearance.vue b/src/client/theme-default/components/VPSwitchAppearance.vue index e23329a8..9613f1eb 100644 --- a/src/client/theme-default/components/VPSwitchAppearance.vue +++ b/src/client/theme-default/components/VPSwitchAppearance.vue @@ -18,13 +18,13 @@ function useAppearance() { const query = window.matchMedia('(prefers-color-scheme: dark)') const classList = document.documentElement.classList - let userPreference = - localStorage.getItem(APPEARANCE_KEY) || site.value.appearance !== true - ? site.value.appearance - : 'auto' + let userPreference = localStorage.getItem(APPEARANCE_KEY) let isDark = - userPreference === 'auto' ? query.matches : userPreference === 'dark' + (site.value.appearance === 'dark' && userPreference == null) || + (userPreference === 'auto' || userPreference == null + ? query.matches + : userPreference === 'dark') query.onchange = (e) => { if (userPreference === 'auto') {