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

@@ -22,7 +22,7 @@ body {
}
.dashboard {
max-width: 1100px;
max-width: 1200px;
margin: 0 auto;
padding: 32px 24px;
}
@@ -55,7 +55,7 @@ body {
.summary-cards {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-columns: repeat(3, 1fr);
gap: 16px;
margin-bottom: 32px;
}
@@ -88,82 +88,89 @@ body {
color: #e5484d;
}
.card-latency .card-value {
color: #356dd2;
.target-board {
display: flex;
flex-direction: column;
gap: 32px;
}
.target-table {
width: 100%;
border-collapse: collapse;
background: rgba(255, 255, 255, 0.85);
.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 {
color: #61728a;
font-size: 0.85rem;
}
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 16px;
}
.target-card {
padding: 16px;
border: 1px solid rgba(49, 83, 126, 0.12);
border-radius: 16px;
overflow: hidden;
box-shadow: 0 4px 16px rgba(34, 57, 91, 0.08);
}
.target-table thead th {
padding: 12px 16px;
text-align: left;
font-size: 0.78rem;
font-weight: 600;
color: #61728a;
text-transform: uppercase;
letter-spacing: 0.05em;
border-bottom: 1px solid rgba(49, 83, 126, 0.1);
background: rgba(236, 243, 252, 0.5);
}
.target-row {
border-radius: 12px;
background: rgba(255, 255, 255, 0.85);
box-shadow: 0 2px 8px rgba(34, 57, 91, 0.06);
cursor: pointer;
transition: background 0.15s;
transition:
box-shadow 0.15s,
transform 0.15s;
}
.target-row:hover {
background: rgba(236, 243, 252, 0.6);
.target-card:hover {
box-shadow: 0 6px 24px rgba(34, 57, 91, 0.14);
transform: translateY(-2px);
}
.target-row.expanded {
background: rgba(236, 243, 252, 0.5);
.card-row-1 {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 12px;
}
.target-row td {
padding: 12px 16px;
border-bottom: 1px solid rgba(49, 83, 126, 0.06);
font-size: 0.9rem;
}
.col-status {
width: 48px;
}
.col-name {
.card-name {
font-weight: 600;
}
.col-target {
color: #61728a;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 0.82rem;
max-width: 260px;
font-size: 0.9rem;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.col-type {
width: 80px;
text-align: center;
.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;
}
.col-duration {
width: 80px;
text-align: right;
font-variant-numeric: tabular-nums;
}
.col-sparkline {
width: 100px;
.card-row-2 {
display: flex;
align-items: center;
justify-content: space-between;
}
.status-dot {
@@ -171,6 +178,7 @@ body {
width: 12px;
height: 12px;
border-radius: 999px;
flex-shrink: 0;
}
.status-up {
@@ -183,75 +191,288 @@ body {
box-shadow: 0 0 0 6px rgba(229, 72, 77, 0.14);
}
.status-bar {
display: flex;
gap: 2px;
align-items: center;
}
.status-bar-block {
width: 6px;
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;
}
.detail-cell {
padding: 0 !important;
border-bottom: 1px solid rgba(49, 83, 126, 0.1) !important;
background: rgba(240, 246, 252, 0.6);
.modal-backdrop {
position: fixed;
inset: 0;
background: rgba(16, 32, 51, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
}
.target-detail {
padding: 20px 24px;
.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;
}
.detail-stats {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 16px;
margin-bottom: 24px;
.modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 24px;
border-bottom: 1px solid rgba(49, 83, 126, 0.1);
}
.detail-stat {
padding: 12px 16px;
border-radius: 12px;
background: rgba(255, 255, 255, 0.7);
.modal-title-row {
display: flex;
align-items: center;
gap: 8px;
}
.detail-stat-label {
display: block;
font-size: 0.75rem;
color: #61728a;
margin-bottom: 4px;
}
.detail-stat-value {
.modal-title {
margin: 0;
font-size: 1.15rem;
font-weight: 700;
font-weight: 600;
}
.text-up {
color: #1fbf75;
.modal-close-btn {
border: none;
background: none;
font-size: 1.5rem;
color: #61728a;
cursor: pointer;
padding: 4px 8px;
line-height: 1;
}
.text-down {
color: #e5484d;
.modal-close-btn:hover {
color: #102033;
}
.detail-trend {
margin-bottom: 20px;
.time-range-picker {
padding: 12px 24px;
border-bottom: 1px solid rgba(49, 83, 126, 0.1);
display: flex;
align-items: center;
gap: 16px;
}
.detail-trend h4,
.detail-history h4 {
.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;
}
.donut-center-label {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -60%);
font-size: 1.25rem;
font-weight: 700;
color: #102033;
}
.trend-chart {
width: 100%;
}
.trend-loading,
.trend-empty {
.trend-empty,
.history-loading,
.history-empty {
padding: 24px;
text-align: center;
color: #94a3b8;
font-size: 0.85rem;
}
.detail-history {
margin-top: 16px;
.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 {
@@ -269,6 +490,14 @@ body {
font-size: 0.78rem;
}
.text-up {
color: #1fbf75;
}
.text-down {
color: #e5484d;
}
.history-time {
color: #61728a;
}
@@ -288,20 +517,48 @@ body {
font-size: 0.8rem;
}
.history-empty {
color: #94a3b8;
font-size: 0.85rem;
margin: 0;
.pagination {
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
padding: 12px 0;
}
.table-loading,
.table-empty {
padding: 40px;
text-align: center;
.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;
background: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(49, 83, 126, 0.12);
border-radius: 16px;
padding: 0 4px;
}
@media (max-width: 768px) {
@@ -313,16 +570,25 @@ body {
grid-template-columns: repeat(2, 1fr);
}
.detail-stats {
grid-template-columns: repeat(2, 1fr);
.card-grid {
grid-template-columns: 1fr;
}
.col-type,
.col-sparkline {
display: none;
.target-card {
width: 100%;
}
.target-row td {
padding: 10px 12px;
.modal-content {
width: 95vw;
max-height: 90vh;
}
.modal-charts {
flex-direction: column;
}
.time-range-picker {
flex-direction: column;
align-items: flex-start;
}
}