fix(theme): fix ssr compile error

This commit is contained in:
pengzhanbo 2025-10-25 12:21:44 +08:00
parent aa6168c31d
commit be565baf59
2 changed files with 4 additions and 2 deletions

View File

@ -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')

View File

@ -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()