1
0

refactor: 全面重构前端 Dashboard 为 TDesign + TanStack Query 分组表格布局

- 卡片式布局改为分组 PrimaryTable,Modal 改为 Drawer
- 手写 hooks 替换为 TanStack Query(轮询/缓存/条件查询)
- CSS 607行精简至73行,颜色迁移至 TDesign tokens
- 可用率进度条颜色按 10% 一档红→绿渐变
- 新增纯函数测试 34 项全通过(排序/筛选/色阶阈值)
- 同步更新主 specs 并归档变更文档
This commit is contained in:
2026-05-12 01:06:53 +08:00
parent 48b40238b8
commit f48e39a615
41 changed files with 1314 additions and 1302 deletions

View File

@@ -1,27 +1,3 @@
:root {
color: #102033;
background: #edf3f8;
font-family:
Inter,
ui-sans-serif,
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
sans-serif;
--dashboard-card-width: 280px;
}
* {
box-sizing: border-box;
}
body {
min-width: 320px;
min-height: 100vh;
margin: 0;
}
.dashboard {
padding: 32px 24px;
width: 100%;
@@ -39,184 +15,10 @@ body {
.dashboard-subtitle {
margin: 0;
color: #61728a;
color: var(--td-text-color-secondary);
font-size: 0.9rem;
}
.error-banner {
padding: 12px 16px;
margin-bottom: 16px;
border: 1px solid rgba(229, 72, 77, 0.25);
border-radius: 12px;
color: #9f2228;
background: rgba(255, 240, 240, 0.8);
font-size: 0.85rem;
}
.summary-cards {
display: flex;
flex-wrap: wrap;
gap: 16px;
margin-bottom: 32px;
}
.summary-card {
width: var(--dashboard-card-width);
flex-shrink: 0;
padding: 20px;
border: 1px solid rgba(49, 83, 126, 0.12);
border-radius: 16px;
background: rgba(255, 255, 255, 0.85);
box-shadow: 0 4px 16px rgba(34, 57, 91, 0.08);
transition:
transform 0.3s ease,
box-shadow 0.3s ease;
}
.summary-card:hover {
box-shadow: 0 8px 32px rgba(34, 57, 91, 0.12);
transform: translateY(-4px);
}
.card-value {
font-size: 1.75rem;
font-weight: 700;
letter-spacing: -0.02em;
}
.card-label {
margin-top: 4px;
color: #61728a;
font-size: 0.8rem;
}
.card-up .card-value {
color: #1fbf75;
}
.card-down .card-value {
color: #e5484d;
}
.target-board {
display: flex;
flex-direction: column;
gap: 32px;
}
.target-group {
display: flex;
flex-direction: column;
gap: 12px;
}
.group-header {
display: flex;
align-items: baseline;
gap: 8px;
}
.group-title {
margin: 0;
font-size: 1.1rem;
font-weight: 600;
}
.group-stats {
display: flex;
align-items: center;
gap: 6px;
}
.stat-badge {
padding: 2px 8px;
border-radius: 6px;
font-size: 0.75rem;
font-weight: 600;
min-width: 24px;
text-align: center;
}
.stat-badge-total {
background: rgba(53, 109, 210, 0.1);
color: #356dd2;
}
.stat-badge-up {
background: rgba(31, 191, 117, 0.1);
color: #1fbf75;
}
.stat-badge-down {
background: rgba(229, 72, 77, 0.1);
color: #e5484d;
}
.card-grid {
display: flex;
flex-wrap: wrap;
gap: 16px;
}
.target-card {
width: var(--dashboard-card-width);
flex-shrink: 0;
padding: 16px;
border: 1px solid rgba(49, 83, 126, 0.12);
border-radius: 12px;
background: rgba(255, 255, 255, 0.85);
box-shadow: 0 2px 8px rgba(34, 57, 91, 0.06);
cursor: pointer;
transition:
box-shadow 0.3s ease,
transform 0.3s ease;
display: flex;
flex-direction: column;
gap: 12px;
}
.target-card:hover {
box-shadow: 0 6px 24px rgba(34, 57, 91, 0.14);
transform: translateY(-2px);
}
.card-header {
display: flex;
align-items: center;
gap: 8px;
}
.card-name {
font-weight: 600;
font-size: 0.9rem;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.card-type-badge {
padding: 2px 8px;
border-radius: 6px;
background: rgba(53, 109, 210, 0.1);
color: #356dd2;
font-size: 0.72rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.04em;
}
.card-status-bar {
display: flex;
width: 100%;
}
.card-sparkline {
display: flex;
width: 100%;
height: 40px;
}
.status-dot {
display: inline-block;
width: 12px;
@@ -225,16 +27,6 @@ body {
flex-shrink: 0;
}
.status-up {
background: #1fbf75;
box-shadow: 0 0 0 6px rgba(31, 191, 117, 0.14);
}
.status-down {
background: #e5484d;
box-shadow: 0 0 0 6px rgba(229, 72, 77, 0.14);
}
.status-bar {
display: flex;
gap: 2px;
@@ -243,173 +35,16 @@ body {
}
.status-bar-block {
width: 6px;
flex: 1;
min-width: 0;
height: 16px;
border-radius: 2px;
}
.status-bar-up {
background: #1fbf75;
}
.status-bar-down {
background: #e5484d;
}
.status-bar-empty {
background: #e2e8f0;
}
.sparkline-empty {
color: #94a3b8;
font-size: 0.85rem;
}
.modal-backdrop {
position: fixed;
inset: 0;
background: rgba(16, 32, 51, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
}
.modal-content {
width: 80vw;
max-height: 85vh;
background: #fff;
border-radius: 16px;
box-shadow: 0 16px 48px rgba(16, 32, 51, 0.2);
overflow-y: auto;
display: flex;
flex-direction: column;
}
.modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 24px;
border-bottom: 1px solid rgba(49, 83, 126, 0.1);
}
.modal-title-row {
display: flex;
align-items: center;
gap: 8px;
}
.modal-title {
margin: 0;
font-size: 1.15rem;
font-weight: 600;
}
.modal-close-btn {
border: none;
background: none;
font-size: 1.5rem;
color: #61728a;
cursor: pointer;
padding: 4px 8px;
line-height: 1;
}
.modal-close-btn:hover {
color: #102033;
}
.time-range-picker {
padding: 12px 24px;
border-bottom: 1px solid rgba(49, 83, 126, 0.1);
display: flex;
align-items: center;
gap: 16px;
}
.time-shortcuts {
display: flex;
gap: 6px;
}
.time-shortcut-btn {
padding: 4px 12px;
border: 1px solid rgba(49, 83, 126, 0.2);
border-radius: 6px;
background: transparent;
color: #42546c;
font-size: 0.82rem;
cursor: pointer;
transition: all 0.15s;
}
.time-shortcut-btn:hover {
background: rgba(53, 109, 210, 0.08);
}
.time-shortcut-btn.active {
background: #356dd2;
color: #fff;
border-color: #356dd2;
}
.time-inputs {
display: flex;
align-items: center;
gap: 6px;
}
.time-input {
padding: 4px 8px;
border: 1px solid rgba(49, 83, 126, 0.2);
border-radius: 6px;
font-size: 0.82rem;
color: #102033;
}
.time-separator {
color: #61728a;
}
.modal-body {
display: flex;
flex-direction: column;
padding: 20px 24px;
gap: 24px;
flex: 1;
}
.modal-charts {
display: flex;
gap: 24px;
align-items: flex-start;
}
.modal-chart-section {
flex: 1;
}
.modal-chart-section h4 {
margin: 0 0 12px;
font-size: 0.9rem;
color: #42546c;
}
.modal-history-section {
display: flex;
flex-direction: column;
min-height: 0;
}
.modal-history-section h4 {
margin: 0 0 12px;
font-size: 0.9rem;
color: #42546c;
}
.status-donut {
position: relative;
display: flex;
justify-content: center;
}
.donut-center-label {
@@ -419,7 +54,6 @@ body {
transform: translate(-50%, -60%);
font-size: 1.25rem;
font-weight: 700;
color: #102033;
}
.trend-chart {
@@ -427,181 +61,13 @@ body {
}
.trend-loading,
.trend-empty,
.history-loading,
.history-empty {
.trend-empty {
padding: 24px;
text-align: center;
color: #94a3b8;
color: var(--td-text-color-placeholder);
font-size: 0.85rem;
}
.history-table {
width: 100%;
border-collapse: collapse;
border: 1px solid #d1d9e6;
border-radius: 8px;
overflow: hidden;
font-size: 0.85rem;
}
.history-table thead {
background: #f0f4fa;
}
.history-table th {
padding: 10px 12px;
text-align: left;
font-size: 0.78rem;
font-weight: 600;
color: #61728a;
text-transform: uppercase;
letter-spacing: 0.04em;
border-bottom: 1px solid #d1d9e6;
}
.history-table td {
padding: 10px 12px;
border-bottom: 1px solid #e8edf4;
}
.history-table tbody tr:last-child td {
border-bottom: none;
}
.history-table tbody tr:hover {
background: rgba(236, 243, 252, 0.6);
}
.ht-col-status {
width: 60px;
}
.ht-col-time {
width: 170px;
}
.ht-col-detail {
width: 100px;
}
.ht-col-latency {
width: 80px;
text-align: right;
}
.ht-col-error {
width: auto;
}
.ht-status {
font-weight: 700;
font-size: 0.78rem;
}
.ht-time {
color: #61728a;
}
.ht-detail {
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
color: #42546c;
font-size: 0.82rem;
}
.ht-latency {
font-variant-numeric: tabular-nums;
color: #356dd2;
text-align: right;
}
.ht-error {
color: #e5484d;
font-size: 0.82rem;
}
.history-item {
display: flex;
gap: 12px;
align-items: center;
padding: 8px 12px;
border-radius: 8px;
background: rgba(255, 255, 255, 0.6);
font-size: 0.85rem;
}
.history-status {
font-weight: 700;
font-size: 0.78rem;
}
.text-up {
color: #1fbf75;
}
.text-down {
color: #e5484d;
}
.history-time {
color: #61728a;
}
.history-code {
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
color: #42546c;
}
.history-latency {
font-variant-numeric: tabular-nums;
color: #356dd2;
}
.history-error {
color: #e5484d;
font-size: 0.8rem;
}
.pagination {
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
padding: 12px 0;
}
.pagination-btn {
border: 1px solid rgba(49, 83, 126, 0.2);
border-radius: 6px;
background: transparent;
color: #42546c;
padding: 4px 10px;
font-size: 0.82rem;
cursor: pointer;
}
.pagination-btn:hover:not(:disabled) {
background: rgba(53, 109, 210, 0.08);
}
.pagination-btn:disabled {
opacity: 0.4;
cursor: default;
}
.pagination-btn.active {
background: #356dd2;
color: #fff;
border-color: #356dd2;
}
.pagination-items {
display: flex;
align-items: center;
gap: 4px;
}
.pagination-ellipsis {
color: #94a3b8;
padding: 0 4px;
.row-down {
background: color-mix(in srgb, var(--td-error-color) 6%, transparent) !important;
}