From dd72908e0e91d43a00ee75dda96b549760f0a2f0 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Tue, 26 May 2026 09:46:36 +0800 Subject: [PATCH] =?UTF-8?q?60s=20=E8=BD=AE=E8=AF=A2=E6=89=A9=E5=B1=95?= =?UTF-8?q?=EF=BC=9A=E8=B7=91=E9=81=93=E6=9B=B2=E7=BA=BF=20+=20=E7=AB=99?= =?UTF-8?q?=E7=82=B9=E8=A7=82=E6=B5=8B=E5=90=8C=E6=AD=A5=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原来只轮询 summary 拿 current.temp 更新数字。 现在同时 fetch detail?depth=full 合并 amos/runway_plate_history/ airport_primary_today_obs 等字段,跑道曲线和站点线每 60s 刷新。 后端 CITY_FULL_CACHE_TTL_SEC=60 保证轻量命中缓存。 --- .../LiveTemperatureThresholdChart.tsx | 38 ++++++++++-- .../dashboard/scan-terminal/LoadingSignal.tsx | 61 +++++++++++++++---- .../__tests__/refreshCadencePolicy.test.ts | 4 +- 3 files changed, 86 insertions(+), 17 deletions(-) diff --git a/frontend/components/dashboard/scan-terminal/LiveTemperatureThresholdChart.tsx b/frontend/components/dashboard/scan-terminal/LiveTemperatureThresholdChart.tsx index 36a52dce..708e2839 100644 --- a/frontend/components/dashboard/scan-terminal/LiveTemperatureThresholdChart.tsx +++ b/frontend/components/dashboard/scan-terminal/LiveTemperatureThresholdChart.tsx @@ -1211,10 +1211,11 @@ export function LiveTemperatureThresholdChart({ }; }, [city, row, isActive, slotIndex]); - // ── 60s lightweight live-temp poll ── + // ── 60s live poll: summary (number) + detail amos/runway (curves) ── useEffect(() => { if (!city) return; - const fetchLiveTemp = () => { + const poll = () => { + // Lightweight: current temp number fetch(`/api/city/${encodeURIComponent(city)}/summary`) .then((res) => (res.ok ? res.json() : null)) .then((payload) => { @@ -1223,9 +1224,38 @@ export function LiveTemperatureThresholdChart({ if (temp !== null) setLiveTemp(temp); }) .catch(() => {}); + + // Refresh runway curves and station observations + fetch(`/api/city/${encodeURIComponent(city)}/detail?depth=full&force_refresh=false`) + .then((res) => (res.ok ? res.json() : null)) + .then((json) => { + if (!json) return; + setHourly((prev) => { + if (!prev) return prev; + return { + ...prev, + amos: json.amos ?? prev.amos, + airportPrimary: json.airport_primary ?? prev.airportPrimary, + airportCurrent: json.airport_current ?? prev.airportCurrent, + airportPrimaryTodayObs: (json as any)?.official?.airport_primary_today_obs + || json.airport_primary_today_obs + || prev.airportPrimaryTodayObs, + runwayPlateHistory: (json as any)?.runway_plate_history + || (json.amos as any)?.runway_plate_history + || prev.runwayPlateHistory, + settlementTodayObs: (json as any).timeseries?.settlement_today_obs + || (json as any)?.settlement_today_obs + || prev.settlementTodayObs, + metarTodayObs: (json as any).timeseries?.metar_today_obs + || (json as any)?.metar_today_obs + || prev.metarTodayObs, + }; + }); + }) + .catch(() => {}); }; - fetchLiveTemp(); - const id = setInterval(fetchLiveTemp, 60_000); + poll(); + const id = setInterval(poll, 60_000); return () => clearInterval(id); }, [city]); diff --git a/frontend/components/dashboard/scan-terminal/LoadingSignal.tsx b/frontend/components/dashboard/scan-terminal/LoadingSignal.tsx index 514c9038..99c96745 100644 --- a/frontend/components/dashboard/scan-terminal/LoadingSignal.tsx +++ b/frontend/components/dashboard/scan-terminal/LoadingSignal.tsx @@ -11,21 +11,60 @@ export function LoadingSignal({ }) { return (
-