From 799abd71b08540e19c1ec94e128cbb852850f3fb Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Wed, 8 Apr 2026 20:22:32 +0800 Subject: [PATCH] Show syncing state while loading city snapshot --- frontend/components/dashboard/DetailPanel.tsx | 17 +++++++++++++++-- frontend/hooks/useDashboardStore.tsx | 8 +++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/frontend/components/dashboard/DetailPanel.tsx b/frontend/components/dashboard/DetailPanel.tsx index c207084e..20795d7b 100644 --- a/frontend/components/dashboard/DetailPanel.tsx +++ b/frontend/components/dashboard/DetailPanel.tsx @@ -199,6 +199,8 @@ export function DetailPanel() { selectedCityItem?.airport || selectedSummary?.icao || (locale === "en-US" ? "Airport pending" : "机场待确认"); + const isBasicSummaryLoading = + !detail && !selectedSummary && store.loadingState.cityDetail; const blurActiveElement = () => { if (typeof document === "undefined") return; const active = document.activeElement; @@ -379,6 +381,13 @@ export function DetailPanel() { <>

{locale === "en-US" ? "City Snapshot" : "城市概览"}

+ {isBasicSummaryLoading ? ( +
+ {locale === "en-US" + ? "Syncing public city snapshot..." + : "正在同步城市基础信息..."} +
+ ) : null}
@@ -406,8 +415,12 @@ export function DetailPanel() { {basicDeb != null ? `${basicDeb}${selectedSummary?.temp_symbol || ""}` : locale === "en-US" - ? "Pending" - : "待更新"} + ? isBasicSummaryLoading + ? "Syncing..." + : "Pending" + : isBasicSummaryLoading + ? "同步中..." + : "待更新"}
diff --git a/frontend/hooks/useDashboardStore.tsx b/frontend/hooks/useDashboardStore.tsx index cbf9291f..be421f17 100644 --- a/frontend/hooks/useDashboardStore.tsx +++ b/frontend/hooks/useDashboardStore.tsx @@ -588,6 +588,7 @@ export function DashboardStoreProvider({ } const access = proAccessRef.current; if (!access.authenticated || !access.subscriptionActive) { + setLoadingState((current) => ({ ...current, cityDetail: true })); if (!citySummariesRef.current[cityName]) { try { const summary = await dashboardClient.getCitySummary(cityName); @@ -595,7 +596,12 @@ export function DashboardStoreProvider({ ...current, [cityName]: summary, })); - } catch {} + } catch { + } finally { + setLoadingState((current) => ({ ...current, cityDetail: false })); + } + } else { + setLoadingState((current) => ({ ...current, cityDetail: false })); } return; }