From 41f70470ec7b3f20d21a73361b3fc4f341d32668 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Mon, 7 Sep 2026 10:10:44 +0800 Subject: [PATCH] =?UTF-8?q?perf(listings):=20=E4=BC=98=E5=8C=96=E4=BB=8E?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E8=BF=94=E5=9B=9E=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E7=9A=84=E6=BB=9A=E5=8A=A8=E6=81=A2=E5=A4=8D=E4=BD=93=E9=AA=8C?= =?UTF-8?q?=EF=BC=8C=E6=B6=88=E9=99=A4=E9=A1=B6=E9=83=A8=E9=97=AA=E8=B7=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listings/composables/useListingQuery.ts | 29 ++++ .../src/features/listings/views/HomeView.vue | 127 +++++++++++++----- .../listings/views/MobileHomeView.vue | 16 ++- .../views/MobileListingDetailView.vue | 7 +- frontend/src/stores/pcHomeCache.ts | 92 +++++++++++++ 5 files changed, 228 insertions(+), 43 deletions(-) create mode 100644 frontend/src/stores/pcHomeCache.ts diff --git a/frontend/src/features/listings/composables/useListingQuery.ts b/frontend/src/features/listings/composables/useListingQuery.ts index c42e6e1..5424116 100644 --- a/frontend/src/features/listings/composables/useListingQuery.ts +++ b/frontend/src/features/listings/composables/useListingQuery.ts @@ -122,14 +122,43 @@ export function useListingQuery( } ) + function restoreSnapshot(snapshot: { + listings: Listing[] + totalListings: number + zoneCounts: Record + currentPage: number + hasMoreListings: boolean + }) { + listings.value = snapshot.listings.slice() + totalListings.value = snapshot.totalListings + zoneCounts.value = { ...snapshot.zoneCounts } + currentPage.value = snapshot.currentPage + hasMoreListings.value = snapshot.hasMoreListings + loading.value = false + loadingMore.value = false + } + + function getSnapshot() { + return { + listings: listings.value.slice(), + totalListings: totalListings.value, + zoneCounts: { ...zoneCounts.value }, + currentPage: currentPage.value, + hasMoreListings: hasMoreListings.value, + } + } + return { loading, loadingMore, listings, totalListings, zoneCounts, + currentPage, hasMoreListings, loadListingsPage, zoneCount, + restoreSnapshot, + getSnapshot, } } diff --git a/frontend/src/features/listings/views/HomeView.vue b/frontend/src/features/listings/views/HomeView.vue index 7db1d46..88b3c85 100644 --- a/frontend/src/features/listings/views/HomeView.vue +++ b/frontend/src/features/listings/views/HomeView.vue @@ -1,6 +1,7 @@