跑道观测面板每 60 秒自动刷新观测时间
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useCallback, useEffect, useMemo } from "react";
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
||||||
import { useCityDetails, useDashboardActions } from "@/hooks/useDashboardStore";
|
import { useCityDetails, useDashboardActions } from "@/hooks/useDashboardStore";
|
||||||
import { useI18n } from "@/hooks/useI18n";
|
import { useI18n } from "@/hooks/useI18n";
|
||||||
import type { CityDetail } from "@/lib/dashboard-types";
|
import type { CityDetail } from "@/lib/dashboard-types";
|
||||||
@@ -117,9 +117,21 @@ export function RunwayObservationsPanel() {
|
|||||||
[ensureCityDetail],
|
[ensureCityDetail],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void loadAll();
|
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(
|
const cards = useMemo(
|
||||||
() =>
|
() =>
|
||||||
|
|||||||
Reference in New Issue
Block a user