Skip to content

Commit

Permalink
docs: 支持点击放大文档中的图片
Browse files Browse the repository at this point in the history
  • Loading branch information
amtoaer committed Jul 23, 2024
1 parent e25339c commit aefe720
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/.vitepress/theme/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.medium-zoom-overlay {
z-index: 30;
}

.medium-zoom-image--opened {
z-index: 31;
}
22 changes: 22 additions & 0 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import DefaultTheme from "vitepress/theme";
import { onMounted, watch, nextTick } from "vue";
import { useRoute } from "vitepress";
import mediumZoom from "medium-zoom";
import "./index.css";

export default {
...DefaultTheme,
setup() {
const route = useRoute();
const initZoom = () => {
mediumZoom(".main img", { background: "var(--vp-c-bg)" });
};
onMounted(() => {
initZoom();
});
watch(
() => route.path,
() => nextTick(() => initZoom()),
);
},
};
Binary file modified docs/bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"dependencies": {},
"devDependencies": {
"markdown-it-task-lists": "^2.1.1",
"medium-zoom": "^1.1.0",
"vitepress": "^1.2.3"
},
"scripts": {
Expand Down

0 comments on commit aefe720

Please sign in to comment.