import type { SkeletonProps } from "tdesign-react"; import { useState } from "react"; import { Alert, Layout, Menu, RadioGroup, Skeleton } from "tdesign-react"; import { RefreshCountdown } from "./components/RefreshCountdown"; import { SummaryCards } from "./components/SummaryCards"; import { TargetBoard } from "./components/TargetBoard"; import { TargetDetailDrawer } from "./components/TargetDetailDrawer"; import { useDashboard } from "./hooks/use-queries"; import { useTargetDetail } from "./hooks/use-target-detail"; const { Content, Header } = Layout; const DEFAULT_REFRESH_INTERVAL_MS = 30000; const DASHBOARD_SKELETON_ROW_COL: SkeletonProps["rowCol"] = [ [{ height: "112px", type: "rect", width: "100%" }], [{ height: "56px", type: "rect", width: "100%" }], [{ height: "320px", type: "rect", width: "100%" }], ]; const REFRESH_OPTIONS = [ { label: "手动", value: 0 }, { label: "10秒", value: 10000 }, { label: "30秒", value: 30000 }, { label: "1分钟", value: 60000 }, { label: "5分钟", value: 300000 }, ] as const; export function App() { const [refreshInterval, setRefreshInterval] = useState(DEFAULT_REFRESH_INTERVAL_MS); const dashboardRefetchInterval = refreshInterval === 0 ? false : refreshInterval; const { data: dashboard, dataUpdatedAt: dashboardUpdatedAt, error: dashboardError, isFetching: dashboardFetching, isLoading: dashboardLoading, refetch: refetchDashboard, } = useDashboard(dashboardRefetchInterval); const { activeTab, closeDrawer, handlePageChange, handleTabChange, handleTimeChange, historyData, historyLoading, metricsData, metricsLoading, openDrawer, selectedTarget, timeFrom, timeTo, } = useTargetDetail(); const isManualRefresh = refreshInterval === 0; const handleIntervalChange = (value: number) => { void refetchDashboard(); setRefreshInterval(value); }; return (
DiAL 统一拨测平台 } operations={
({ label: option.label, value: option.value }))} theme="button" value={refreshInterval} variant="default-filled" /> void refetchDashboard()} refreshInterval={refreshInterval} />
} />
{dashboardError && } {dashboardLoading ? ( ) : ( <> )}
); }