From 9d8c59f741f6d3671cb8aa059397116456725aed Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Sun, 17 May 2026 21:20:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9F=8E=E5=B8=82=E5=86=B3?= =?UTF-8?q?=E7=AD=96=E5=8D=A1=E5=88=87=E6=8D=A2=E6=97=B6=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E7=99=BD=E5=B1=8F=E5=92=8C=E7=AC=AC=E4=BA=8C=E5=9F=8E=E5=B8=82?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MapCanvas 改为始终挂载,视图切换用 display:none 隐藏而非卸载, 避免 Leaflet 重初始化时容器尺寸为 0 导致白屏 - handleMapCitySelect 在 matchedRow 为空时主动调用 ensureCityDetail 预加载城市详情,不再依赖 hydration 队列异步补拉 --- .../dashboard/ScanTerminalDashboard.tsx | 65 +++++++++++-------- .../__tests__/temperatureChartData.test.ts | 2 +- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/frontend/components/dashboard/ScanTerminalDashboard.tsx b/frontend/components/dashboard/ScanTerminalDashboard.tsx index 40d7f542..7e80fc05 100644 --- a/frontend/components/dashboard/ScanTerminalDashboard.tsx +++ b/frontend/components/dashboard/ScanTerminalDashboard.tsx @@ -289,8 +289,15 @@ function ScanTerminalScreen() { setMapSelectedCityName(cityName); lastMapSelectedCityRef.current = normalizeCityKey(cityName); const matchedRow = findRowForCity(timeSortedRows, cityName); - if (matchedRow) store.preloadCityFromRow(matchedRow); - setSelectedRowId(matchedRow?.id || null); + if (matchedRow) { + store.preloadCityFromRow(matchedRow); + setSelectedRowId(matchedRow.id); + } else { + // City not in scan rows — still preload its detail so the decision + // card can render immediately instead of showing a loading spinner. + void store.ensureCityDetail(cityName, false, "panel").catch(() => {}); + setSelectedRowId(null); + } addAiPinnedCity(cityName); setActiveView("analysis"); }, [addAiPinnedCity, store, timeSortedRows]); @@ -352,30 +359,6 @@ function ScanTerminalScreen() { /> ); } - if (resolvedView === "map") { - return ( -
-
- -
-
- ); - } - if (resolvedView === "analysis") { - return ( - - ); - } if (!isPro) { return (
@@ -392,7 +375,35 @@ function ScanTerminalScreen() {
); } - return null; + + // Keep MapCanvas always mounted — hiding with CSS avoids Leaflet + // reinitialization that causes a white background on tab switches. + // The analysis view overlays on top when active. + return ( + <> +
+
+ +
+
+ {resolvedView === "analysis" ? ( + + ) : null} + + ); }; if (proAccess.loading) { diff --git a/frontend/components/dashboard/scan-terminal/__tests__/temperatureChartData.test.ts b/frontend/components/dashboard/scan-terminal/__tests__/temperatureChartData.test.ts index ea79446d..9be53fa2 100644 --- a/frontend/components/dashboard/scan-terminal/__tests__/temperatureChartData.test.ts +++ b/frontend/components/dashboard/scan-terminal/__tests__/temperatureChartData.test.ts @@ -78,7 +78,7 @@ export function runTests() { "Ankara chart should build the DEB original path from MGM hourly data when Open-Meteo hourly is unavailable", ); assert( - ankaraChartData?.datasets.debSeries.length >= 4, + (ankaraChartData?.datasets.debSeries.length ?? 0) >= 4, "Ankara chart should build the DEB original path from MGM hourly data", ); assert(