1
0

refactor: 优化卡片显示一致性与可扩展性

- 统一 Summary Cards 和 Target Cards 宽度为 280px(CSS 变量控制)
- 分组统计改为徽章展示(纯数字 + 颜色区分)
- 目标名称添加 title 属性支持显示完整名称
- 建立类型映射系统,Command 显示为 CMD,支持扩展
- 移除移动端响应式代码,简化维护
- 新增 target-type-display 能力规格
- 更新 card-dashboard 和 target-detail-modal 规格
This commit is contained in:
2026-05-11 18:36:16 +08:00
parent 48a9e96ec2
commit 767f26617e
10 changed files with 163 additions and 34 deletions

View File

@@ -11,9 +11,17 @@ export function GroupHeader({ name, total, up, down }: GroupHeaderProps) {
return (
<div className="group-header">
<h2 className="group-title">{displayName}</h2>
<span className="group-stats">
({total}, {up} UP / {down} DOWN)
</span>
<div className="group-stats">
<span className="stat-badge stat-badge-total" title="总数">
{total}
</span>
<span className="stat-badge stat-badge-up" title="正常">
{up}
</span>
<span className="stat-badge stat-badge-down" title="异常">
{down}
</span>
</div>
</div>
);
}

View File

@@ -2,6 +2,7 @@ import type { TargetStatus } from "../../shared/api";
import { StatusDot } from "./StatusDot";
import { StatusBar } from "./StatusBar";
import { MiniSparkline } from "./MiniSparkline";
import { getTargetTypeDisplay } from "../constants/target-type-display";
interface TargetCardProps {
target: TargetStatus;
@@ -15,8 +16,10 @@ export function TargetCard({ target, onClick }: TargetCardProps) {
<div className="target-card" onClick={onClick} role="button" tabIndex={0}>
<div className="card-header">
<StatusDot up={!!isUp} />
<span className="card-name">{target.name}</span>
<span className="card-type-badge">{target.type === "http" ? "HTTP" : "Command"}</span>
<span className="card-name" title={target.name}>
{target.name}
</span>
<span className="card-type-badge">{getTargetTypeDisplay(target.type)}</span>
</div>
<div className="card-status-bar">
<StatusBar samples={target.recentSamples} />

View File

@@ -4,6 +4,7 @@ import { StatusDonut } from "./StatusDonut";
import { StatusDot } from "./StatusDot";
import { TimeRangePicker } from "./TimeRangePicker";
import { Pagination } from "./Pagination";
import { getTargetTypeDisplay } from "../constants/target-type-display";
interface TargetDetailModalProps {
target: TargetStatus;
@@ -48,7 +49,7 @@ export function TargetDetailModal({
<div className="modal-title-row">
<StatusDot up={!!isUp} />
<h3 className="modal-title">{target.name}</h3>
<span className="card-type-badge">{target.type === "http" ? "HTTP" : "Command"}</span>
<span className="card-type-badge">{getTargetTypeDisplay(target.type)}</span>
</div>
<button className="modal-close-btn" onClick={onClose}>
&times;