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

@@ -479,4 +479,53 @@ targets:
expect(t.command.env.PATH).toBeDefined();
}
});
test("解析 group 字段", async () => {
const configPath = join(tempDir, "group.yaml");
await writeFile(
configPath,
`targets:
- name: "grouped"
type: http
group: "搜索引擎"
http:
url: "http://example.com"
`,
);
const config = await loadConfig(configPath);
expect(config.targets[0]!.group).toBe("搜索引擎");
});
test("group 字段默认为 default", async () => {
const configPath = join(tempDir, "no-group.yaml");
await writeFile(
configPath,
`targets:
- name: "no-group"
type: http
http:
url: "http://example.com"
`,
);
const config = await loadConfig(configPath);
expect(config.targets[0]!.group).toBe("default");
});
test("非法 group 类型抛出错误", async () => {
const configPath = join(tempDir, "bad-group.yaml");
await writeFile(
configPath,
`targets:
- name: "test"
type: http
group: 123
http:
url: "http://example.com"
`,
);
await expect(loadConfig(configPath)).rejects.toThrow("group 字段必须为字符串");
});
});