fix: 修复window not defined导致的构建错误

This commit is contained in:
ZiuChen 2023-01-10 18:15:37 +08:00
parent 682afb1eae
commit ca7817f499
2 changed files with 4 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules node_modules
dist dist
cache cache
.temp

View File

@ -1,6 +1,6 @@
import DefaultTheme from 'vitepress/theme' import DefaultTheme from 'vitepress/theme'
import { onMounted, watch, nextTick, watchEffect } from 'vue' import { onMounted, watch, nextTick, watchEffect } from 'vue'
import { useRouter } from 'vitepress' import { inBrowser, useRouter } from 'vitepress'
import mediumZoom from 'medium-zoom' import mediumZoom from 'medium-zoom'
import Title from '../components/Title.vue' import Title from '../components/Title.vue'
import './index.css' import './index.css'
@ -17,7 +17,7 @@ export default {
watchEffect(() => { watchEffect(() => {
// 将router.route.path作为依赖收集 首次访问即添加监听 // 将router.route.path作为依赖收集 首次访问即添加监听
const path = router.route.path const path = router.route.path
nextTick(() => mediumZoom('.main img', { background: 'var(--vp-c-bg)' })) nextTick(() => (inBrowser ? mediumZoom('.main img', { background: 'var(--vp-c-bg)' }) : null))
}) })
} }
} }