mirror of
https://github.com/ZiuChen/ZiuChen.github.io.git
synced 2025-12-18 17:04:16 +08:00
feat: 添加MediumZoom点击缩放图片
This commit is contained in:
7
docs/.vitepress/theme/index.css
Normal file
7
docs/.vitepress/theme/index.css
Normal file
@@ -0,0 +1,7 @@
|
||||
.medium-zoom-overlay {
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.medium-zoom-image {
|
||||
z-index: 21;
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
import DefaultTheme from 'vitepress/theme'
|
||||
import { onMounted, watch, nextTick, watchEffect } from 'vue'
|
||||
import { useRouter } from 'vitepress'
|
||||
import mediumZoom from 'medium-zoom'
|
||||
import Title from '../components/Title.vue'
|
||||
import './index.css'
|
||||
|
||||
export default {
|
||||
...DefaultTheme,
|
||||
@@ -7,5 +11,13 @@ export default {
|
||||
DefaultTheme.enhanceApp(ctx)
|
||||
const { app } = ctx
|
||||
app.component('Title', Title)
|
||||
},
|
||||
setup() {
|
||||
const router = useRouter()
|
||||
watchEffect(() => {
|
||||
// 将router.route.path作为依赖收集 首次访问即添加监听
|
||||
const path = router.route.path
|
||||
nextTick(() => mediumZoom('.main img', { background: 'var(--vp-c-bg)' }))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user