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

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

3
.gitignore vendored
View File

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

View File

@ -1,6 +1,6 @@
import DefaultTheme from 'vitepress/theme'
import { onMounted, watch, nextTick, watchEffect } from 'vue'
import { useRouter } from 'vitepress'
import { inBrowser, useRouter } from 'vitepress'
import mediumZoom from 'medium-zoom'
import Title from '../components/Title.vue'
import './index.css'
@ -17,7 +17,7 @@ export default {
watchEffect(() => {
// 将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))
})
}
}