You've already forked AstralRinth
forked from didirus/AstralRinth
Disable system theme detection (#1071)
This commit is contained in:
@@ -1,23 +1,24 @@
|
|||||||
export default defineNuxtPlugin((nuxtApp) => {
|
export default defineNuxtPlugin((nuxtApp) => {
|
||||||
const themeStore = useTheme()
|
const themeStore = useTheme()
|
||||||
|
|
||||||
nuxtApp.hook('app:mounted', () => {
|
// nuxtApp.hook('app:mounted', () => {
|
||||||
if (process.client && themeStore.value.preference === 'system') {
|
// if (process.client && themeStore.value.preference === 'system') {
|
||||||
const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: light)')
|
// 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)
|
nuxtApp.provide('colorMode', themeStore.value)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user