Skip to content

Commit

Permalink
perf: 调整 滚动交互
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo committed Dec 26, 2023
1 parent 3b00215 commit a81947a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions theme/src/client/components/BlogExtract.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script lang="ts" setup>
import { useScrollLock } from '@vueuse/core'
import { computed, ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import { useBlogExtract, useThemeLocaleData } from '../composables/index.js'
import { inBrowser } from '../utils/index.js'
import AutoLink from './AutoLink.vue'
import IconArchive from './icons/IconArchive.vue'
import IconBlogExt from './icons/IconBlogExt.vue'
Expand All @@ -15,10 +17,22 @@ const avatar = computed(() => theme.value.avatar)
const { hasBlogExtract, tags, archives } = useBlogExtract()
const open = ref(false)
const isLocked = useScrollLock(inBrowser ? document.body : null)
watch(() => route.path, () => {
open.value = false
})
watch(
[() => open.value],
() => {
if (open.value) {
isLocked.value = true
} else isLocked.value = false
},
{ immediate: true, flush: 'post' }
)
const showBlogExtract = computed(() => {
return avatar.value || hasBlogExtract.value
})
Expand Down Expand Up @@ -66,6 +80,7 @@ const showBlogExtract = computed(() => {
box-shadow: var(--vp-shadow-2);
z-index: calc(var(--vp-z-index-nav) - 1);
background-color: var(--vp-c-bg);
cursor: pointer;
}
.blog-extract .icon {
Expand Down

0 comments on commit a81947a

Please sign in to comment.