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

@@ -0,0 +1,39 @@
import { describe, test, expect } from "bun:test";
import { TARGET_TYPE_DISPLAY, getTargetTypeDisplay } from "../../../src/web/constants/target-type-display";
describe("target-type-display", () => {
describe("TARGET_TYPE_DISPLAY 常量", () => {
test("定义了 http 类型映射", () => {
expect(TARGET_TYPE_DISPLAY.http).toBe("HTTP");
});
test("定义了 command 类型映射", () => {
expect(TARGET_TYPE_DISPLAY.command).toBe("CMD");
});
});
describe("getTargetTypeDisplay 函数", () => {
test("http 类型返回 HTTP", () => {
expect(getTargetTypeDisplay("http")).toBe("HTTP");
});
test("command 类型返回 CMD", () => {
expect(getTargetTypeDisplay("command")).toBe("CMD");
});
test("未知类型返回大写形式", () => {
expect(getTargetTypeDisplay("tcp")).toBe("TCP");
expect(getTargetTypeDisplay("dns")).toBe("DNS");
expect(getTargetTypeDisplay("grpc")).toBe("GRPC");
});
test("空字符串返回空字符串", () => {
expect(getTargetTypeDisplay("")).toBe("");
});
test("已大写的类型保持大写", () => {
expect(getTargetTypeDisplay("HTTP")).toBe("HTTP");
expect(getTargetTypeDisplay("CMD")).toBe("CMD");
});
});
});