跑道观测面板每 60 秒自动刷新观测时间

This commit is contained in:
2569718930@qq.com
2026-05-15 04:36:45 +08:00
parent c2a78e7b62
commit 77488e561a
@@ -1,6 +1,6 @@
"use client";
import { useCallback, useEffect, useMemo } from "react";
import { useCallback, useEffect, useMemo, useRef } from "react";
import { useCityDetails, useDashboardActions } from "@/hooks/useDashboardStore";
import { useI18n } from "@/hooks/useI18n";
import type { CityDetail } from "@/lib/dashboard-types";
@@ -117,9 +117,21 @@ export function RunwayObservationsPanel() {
[ensureCityDetail],
);
const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
useEffect(() => {
void loadAll();
}, [loadAll]);
intervalRef.current = setInterval(() => {
void Promise.allSettled(
CHINA_RUNWAY_CITIES.map((city) =>
ensureCityDetail(city.key, true, "panel"),
),
);
}, 60_000);
return () => {
if (intervalRef.current) clearInterval(intervalRef.current);
};
}, [loadAll, ensureCityDetail]);
const cards = useMemo(
() =>