From 7c46970dfe55db83385cf80785599ca27095ba74 Mon Sep 17 00:00:00 2001 From: UnknownMp Date: Wed, 28 May 2025 20:36:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E7=AB=A0=E8=8A=82?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E5=BD=93=E5=89=8D=E7=AB=A0=E8=8A=82?= =?UTF-8?q?=E9=AB=98=E4=BA=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [BugFix] 修复了搜索页面加载重复的问题 --- src/stores/search.js | 11 +++++------ src/views/SimpleSearch.vue | 2 +- src/views/Work.vue | 17 ++++++++++++++--- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/stores/search.js b/src/stores/search.js index 0360565..27be514 100644 --- a/src/stores/search.js +++ b/src/stores/search.js @@ -13,16 +13,15 @@ export const useSimpleSearchState = defineStore('simpleSearch', () => { const state = ref(null) async function load() { if (pageCount.value && currentPage.value >= pageCount.value){ state.value = 'finish'; return } + state.value = 'loading' let res = await api.workSimpleSearch(keyword.value, currentPage.value) res = res.data - if( pageCount.value ) { - currentPage.value++ - if (currentPage.value > pageCount.value) currentPage.value = pageCount.value - } if (res.code == 0) { - if ( !pageCount.value ) { + currentPage.value++ + if( pageCount.value ) { + if (currentPage.value > pageCount.value) currentPage.value = pageCount.value + } else { pageCount.value = res.pageCount - currentPage.value = res.page } count.value = res.count state.value = import.meta.env.SSR ? 'ssrready' : 'ready' diff --git a/src/views/SimpleSearch.vue b/src/views/SimpleSearch.vue index 584e755..ea919f6 100644 --- a/src/views/SimpleSearch.vue +++ b/src/views/SimpleSearch.vue @@ -39,7 +39,7 @@ onMounted(async () => { isObserver = new IntersectionObserver((entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { - if (simpleSearchState.state == 'ready') simpleSearchState.load() + if (simpleSearchState.state == 'ready' || simpleSearchState.state == 'ssrready') setTimeout(simpleSearchState.load,400) } }) }, { threshold: 1 }) diff --git a/src/views/Work.vue b/src/views/Work.vue index 07c063d..36bbff3 100644 --- a/src/views/Work.vue +++ b/src/views/Work.vue @@ -163,8 +163,12 @@ async function switchWorkWithIndex(target) {

@@ -192,7 +196,11 @@ async function switchWorkWithIndex(target) {
点击跳转 - + {{index + 1}}. {{ chapter.title }} @@ -249,6 +257,9 @@ async function switchWorkWithIndex(target) {