Skip to content

Commit

Permalink
compose: 图片缩放
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxiang committed Jul 10, 2024
1 parent 59b891f commit b6e52f5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/.vitepress/theme/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,11 @@
transform: rotate(1turn);
}
}

.medium-zoom-overlay {
z-index: 2147483646;
}

.medium-zoom-image {
z-index: 2147483647;
}
17 changes: 16 additions & 1 deletion docs/.vitepress/vitepress/components/vp-app.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { onMounted } from 'vue'
import nprogress from 'nprogress'
import { useToggle } from '@vueuse/core'
import { useSidebar } from '../composables/sidebar'
Expand All @@ -10,6 +9,9 @@
import VPSidebar from './vp-sidebar.vue'
import VPContent from './vp-content.vue'
import VPOverlay from './vp-overlay.vue'
import { nextTick, onMounted, watch } from 'vue'
import { useRoute } from 'vitepress'
import mediumZoom from 'medium-zoom'
const [isSidebarOpen, toggleSidebar] = useToggle(false)
const { hasSidebar } = useSidebar()
Expand All @@ -20,7 +22,20 @@
}
})
const route = useRoute();
// 初始化点击图片放大
const initZoom = () => {
//mediumZoom('[data-zoomable]', { background: 'var(--vp-c-bg)' });
mediumZoom('.doc-content img', { background: 'var(--vp-c-bg)' });
};
watch(
() => route.path,
() => nextTick(() => initZoom())
);
onMounted(async () => {
initZoom();
window.addEventListener(
'click',
(e) => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"clipboard-copy": "^4.0.1",
"dayjs": "^1.11.3",
"element-plus": "^2.7.0",
"medium-zoom": "^1.1.0",
"nprogress": "^0.2.0",
"prism-theme-vars": "^0.2.3",
"vue": "^3.2.36"
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b6e52f5

Please sign in to comment.