1
0

feat: 重构 Dashboard 为卡片式分组布局

表格布局替换为按分组展示的卡片式布局,新增 group 字段配置和 TargetBoard/TargetCard 等组件。模态框详情页支持时间范围筛选和分页,SummaryCards 减为 3 个。API 端点变更:trend/history 改用 from/to 参数,history 支持分页。recentSampleCount 硬编码为 30。
This commit is contained in:
2026-05-11 08:54:21 +08:00
parent b8810f1182
commit 548b44d28e
44 changed files with 1676 additions and 557 deletions

View File

@@ -1,14 +1,41 @@
import { useEffect } from "react";
import { useSummary } from "./hooks/useSummary";
import { useTargets } from "./hooks/useTargets";
import { useTargetDetail } from "./hooks/useTargetDetail";
import { SummaryCards } from "./components/SummaryCards";
import { TargetTable } from "./components/TargetTable";
import { TargetBoard } from "./components/TargetBoard";
import { TargetDetailModal } from "./components/TargetDetailModal";
export function App() {
const { data: summary, loading: summaryLoading, error: summaryError } = useSummary();
const { data: targets, loading: targetsLoading, error: targetsError } = useTargets();
const { data: targets, error: targetsError } = useTargets();
const {
selectedTarget,
trendData,
trendLoading,
historyData,
historyLoading,
timeFrom,
timeTo,
openModal,
closeModal,
handleTimeChange,
handlePageChange,
} = useTargetDetail();
const error = summaryError || targetsError;
useEffect(() => {
if (selectedTarget) {
document.body.style.overflow = "hidden";
} else {
document.body.style.overflow = "";
}
return () => {
document.body.style.overflow = "";
};
}, [selectedTarget]);
return (
<main className="dashboard">
<header className="dashboard-header">
@@ -19,7 +46,22 @@ export function App() {
{error && <div className="error-banner">: {error}</div>}
<SummaryCards summary={summary} loading={summaryLoading} />
<TargetTable targets={targets} loading={targetsLoading} />
<TargetBoard targets={targets} onTargetClick={openModal} />
{selectedTarget && (
<TargetDetailModal
target={selectedTarget}
trendData={trendData}
trendLoading={trendLoading}
historyData={historyData}
historyLoading={historyLoading}
timeFrom={timeFrom}
timeTo={timeTo}
onTimeChange={handleTimeChange}
onPageChange={handlePageChange}
onClose={closeModal}
/>
)}
</main>
);
}