From ccf81ff7b9f27789b818f5f126e3e0b240cee34a Mon Sep 17 00:00:00 2001 From: Geometrically <18202329+Geometrically@users.noreply.github.com> Date: Sun, 2 Apr 2023 10:03:17 -0700 Subject: [PATCH] Disable system theme detection (#1071) --- plugins/1.theme.js | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/plugins/1.theme.js b/plugins/1.theme.js index e839923e0..ba2282a82 100644 --- a/plugins/1.theme.js +++ b/plugins/1.theme.js @@ -1,23 +1,24 @@ export default defineNuxtPlugin((nuxtApp) => { const themeStore = useTheme() - nuxtApp.hook('app:mounted', () => { - if (process.client && themeStore.value.preference === 'system') { - const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: light)') + // nuxtApp.hook('app:mounted', () => { + // if (process.client && themeStore.value.preference === 'system') { + // const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: light)') + // + // const setColorScheme = (e) => { + // if (themeStore.value.preference === 'system') { + // if (e.matches) { + // updateTheme('light') + // } else { + // updateTheme('dark') + // } + // } + // } + // + // setColorScheme(colorSchemeQueryList) + // colorSchemeQueryList.addEventListener('change', setColorScheme) + // } + // }) - const setColorScheme = (e) => { - if (themeStore.value.preference === 'system') { - if (e.matches) { - updateTheme('light') - } else { - updateTheme('dark') - } - } - } - - setColorScheme(colorSchemeQueryList) - colorSchemeQueryList.addEventListener('change', setColorScheme) - } - }) nuxtApp.provide('colorMode', themeStore.value) })