From 74497733a969c699d27175612f5dd5dfe27ba4d5 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 11 May 2026 20:46:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.vitepress/theme/index.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vitepress/theme/index.ts | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.vitepress/theme/index.ts b/.vitepress/theme/index.ts index 90db4b6..7ad386f 100644 --- a/.vitepress/theme/index.ts +++ b/.vitepress/theme/index.ts @@ -1,6 +1,36 @@ import DefaultTheme from 'vitepress/theme' +import mediumZoom from 'medium-zoom' +import { onMounted, watch, nextTick } from 'vue' +import { useRoute } from 'vitepress' + import './style/print.css' +import './style/zoom.css' export default { ...DefaultTheme, -} + + setup() { + const route = useRoute() + + const initZoom = () => { + mediumZoom('.main img', { + background: 'rgba(0,0,0,0.8)' + }) + } + + onMounted(() => { + nextTick(() => { + initZoom() + }) + }) + + watch( + () => route.path, + () => { + nextTick(() => { + initZoom() + }) + } + ) + } +} \ No newline at end of file