From 7c0c9e46dd942c1842f6a3c5534b955116baebad Mon Sep 17 00:00:00 2001 From: James Date: Mon, 11 May 2026 20:44:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20.vitepress/theme/style?= =?UTF-8?q?/zoom.css?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加image zoom in/out的样式 --- .vitepress/theme/style/zoom.css | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .vitepress/theme/style/zoom.css diff --git a/.vitepress/theme/style/zoom.css b/.vitepress/theme/style/zoom.css new file mode 100644 index 0000000..382239c --- /dev/null +++ b/.vitepress/theme/style/zoom.css @@ -0,0 +1,7 @@ +.medium-zoom-overlay { + z-index: 9998; +} + +.medium-zoom-image--opened { + z-index: 9999; +} \ No newline at end of file From 6a853d360b3c048b3f5f86d5cfb344f738ca742e Mon Sep 17 00:00:00 2001 From: James Date: Mon, 11 May 2026 20:45:26 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.vitepress/theme/index?= =?UTF-8?q?.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