From c5fdb93ae51e1125daa662fab0f9d2b37682ee31 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Thu, 14 May 2026 00:29:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E6=8E=A7=E9=A1=B5=EF=BC=9A=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=2030s=20=E7=BC=93=E5=AD=98=20+=20=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=20loading=20=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/dashboard/monitoring/MonitorPanel.tsx | 8 +++++++- web/monitor_routes.py | 12 +++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/components/dashboard/monitoring/MonitorPanel.tsx b/frontend/components/dashboard/monitoring/MonitorPanel.tsx index f6830645..c887410e 100644 --- a/frontend/components/dashboard/monitoring/MonitorPanel.tsx +++ b/frontend/components/dashboard/monitoring/MonitorPanel.tsx @@ -33,7 +33,7 @@ function parseRunway(html: string): RunwayPair[] { } export default function MonitorPanel() { - const [cities, setCities] = useState([]); + const [cities, setCities] = useState(null); const [time, setTime] = useState(""); const [notify, setNotify] = useState( () => typeof window !== "undefined" && localStorage.getItem("monitor_notify") !== "off" @@ -87,6 +87,11 @@ export default function MonitorPanel() { {/* Card Grid */} + {cities === null ? ( +
+ Loading… +
+ ) : (
+ )}
); } diff --git a/web/monitor_routes.py b/web/monitor_routes.py index 26a92311..a6efe7ac 100644 --- a/web/monitor_routes.py +++ b/web/monitor_routes.py @@ -118,6 +118,16 @@ def _build_cards() -> list: return cards +_cache = None +_cache_ts = 0 + + @router.get("/m/json") async def monitor_json(): - return _build_cards() + global _cache, _cache_ts + now = __import__("time").time() + if _cache is not None and now - _cache_ts < 30: + return _cache + _cache = _build_cards() + _cache_ts = now + return _cache