You've already forked AstralRinth
forked from didirus/AstralRinth
Fix hydration issue + Edit Page (#1043)
This commit is contained in:
25
plugins/1.theme.js
Normal file
25
plugins/1.theme.js
Normal file
@@ -0,0 +1,25 @@
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
const themeStore = useTheme()
|
||||
|
||||
// TODO: Temporarily removed as it was causing hydration issues
|
||||
// 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)
|
||||
// }
|
||||
// })
|
||||
|
||||
nuxtApp.provide('colorMode', themeStore.value)
|
||||
})
|
||||
@@ -1,24 +0,0 @@
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
const themeStore = useTheme()
|
||||
|
||||
if (process.client && themeStore.value.preference === 'system') {
|
||||
setTimeout(() => {
|
||||
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)
|
||||
}, 100)
|
||||
}
|
||||
|
||||
nuxtApp.provide('colorMode', themeStore.value)
|
||||
})
|
||||
Reference in New Issue
Block a user