From 713b2cfbb76d59be428eaf48976dabd95fb5e7d9 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Fri, 29 Dec 2023 01:38:55 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20blog=20extract=20?= =?UTF-8?q?=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- theme/src/client/components/BlogExtract.vue | 96 +++++++++++++-------- 1 file changed, 58 insertions(+), 38 deletions(-) diff --git a/theme/src/client/components/BlogExtract.vue b/theme/src/client/components/BlogExtract.vue index f9150a89..a07870b7 100644 --- a/theme/src/client/components/BlogExtract.vue +++ b/theme/src/client/components/BlogExtract.vue @@ -15,6 +15,7 @@ const route = useRoute() const avatar = computed(() => theme.value.avatar) const { hasBlogExtract, tags, archives } = useBlogExtract() const open = ref(false) +const lazyOpen = ref(false) const isLocked = useScrollLock(inBrowser ? document.body : null) @@ -22,6 +23,15 @@ watch(() => route.path, () => { open.value = false }) +watch(open, async () => { + if (open.value) { + setTimeout(() => { + lazyOpen.value = true + }, 200) + } + else { lazyOpen.value = false } +}) + watch( [() => open.value], () => { @@ -39,34 +49,38 @@ const showBlogExtract = computed(() => {