fix(theme): fix ssr compile error
This commit is contained in:
parent
aa6168c31d
commit
be565baf59
@ -46,7 +46,9 @@ function noTransition() {
|
||||
|
||||
let defaultTheme: string | undefined
|
||||
watch(() => props.forceDark, () => {
|
||||
if (inBrowser && props.forceDark) {
|
||||
if (!inBrowser || __VUEPRESS_SSR__)
|
||||
return
|
||||
if (props.forceDark) {
|
||||
defaultTheme ??= document.documentElement.dataset.theme
|
||||
document.documentElement.dataset.theme = 'dark'
|
||||
document.documentElement.classList.add('force-dark')
|
||||
|
||||
@ -15,7 +15,7 @@ export function useCssVar(
|
||||
|
||||
function updateCssVar() {
|
||||
const _window = typeof window ? window : null
|
||||
const target = _window?.document.documentElement
|
||||
const target = _window?.document?.documentElement
|
||||
const key = toValue(prop)
|
||||
if (target && key) {
|
||||
const value = _window.getComputedStyle(target).getPropertyValue(key)?.trim()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user