移除跑道观测面板刷新按钮,数据随面板加载自动拉取
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo } from "react";
|
||||||
import { RefreshCw } from "lucide-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";
|
||||||
@@ -115,26 +114,19 @@ export function RunwayObservationsPanel() {
|
|||||||
const isEn = locale === "en-US";
|
const isEn = locale === "en-US";
|
||||||
const { cityDetailsByName } = useCityDetails();
|
const { cityDetailsByName } = useCityDetails();
|
||||||
const { ensureCityDetail } = useDashboardActions();
|
const { ensureCityDetail } = useDashboardActions();
|
||||||
const [refreshing, setRefreshing] = useState(false);
|
|
||||||
|
|
||||||
const loadAll = useCallback(
|
const loadAll = useCallback(
|
||||||
async (force: boolean) => {
|
async () => {
|
||||||
setRefreshing(true);
|
await Promise.allSettled(
|
||||||
try {
|
CHINA_RUNWAY_CITIES.map((city) =>
|
||||||
await Promise.allSettled(
|
ensureCityDetail(city.key, false, "panel"),
|
||||||
CHINA_RUNWAY_CITIES.map((city) =>
|
),
|
||||||
ensureCityDetail(city.key, force, "panel"),
|
);
|
||||||
),
|
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
setRefreshing(false);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[ensureCityDetail],
|
[ensureCityDetail],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void loadAll(false);
|
void loadAll();
|
||||||
}, [loadAll]);
|
}, [loadAll]);
|
||||||
|
|
||||||
const cards = useMemo(
|
const cards = useMemo(
|
||||||
@@ -149,20 +141,9 @@ export function RunwayObservationsPanel() {
|
|||||||
return (
|
return (
|
||||||
<div className="monitor-panel runway-observations-panel">
|
<div className="monitor-panel runway-observations-panel">
|
||||||
<div className="monitor-toolbar">
|
<div className="monitor-toolbar">
|
||||||
<div>
|
<div className="monitor-title">
|
||||||
<div className="monitor-title">
|
{isEn ? "Runway Observations" : "跑道观测"}
|
||||||
{isEn ? "Runway Observations" : "跑道观测"}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="monitor-refresh-button"
|
|
||||||
disabled={refreshing}
|
|
||||||
onClick={() => void loadAll(true)}
|
|
||||||
>
|
|
||||||
<RefreshCw size={14} className={refreshing ? "spin" : undefined} />
|
|
||||||
{isEn ? "Refresh" : "刷新"}
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="monitor-grid">
|
<div className="monitor-grid">
|
||||||
|
|||||||
Reference in New Issue
Block a user