1
0

docs: 同步 spec 文档与 README(修正引用、精简重复、补全说明)

This commit is contained in:
2026-05-11 14:38:09 +08:00
parent 0ee10b47c9
commit 80d5f4cdf4
4 changed files with 34 additions and 93 deletions

View File

@@ -15,18 +15,21 @@ src/
types.ts 类型定义
config-loader.ts YAML 配置解析与校验
store.ts SQLite 数据存储
http-runner.ts HTTP 拨测执行
fetcher.ts HTTP 拨测执行
command-runner.ts 命令行拨测执行
http-expect.ts HTTP 响应断言
command-expect.ts 命令行输出断言
failure.ts 失败信息类型
size.ts 大小单位解析
engine.ts 调度引擎(按 interval 分组、组内并发)
expect/
http.ts HTTP 响应断言
command.ts 命令行输出断言
body.ts HTTP body 断言JSONPath/XPath/CSS
failure.ts 失败信息类型
shared/
api.ts 前后端共享 TypeScript 类型
web/ Vite + React 前端 Dashboard
components/ UI 组件(卡片、分组、模态框、状态条等)
hooks/ 数据轮询和详情管理 hooks
utils/ 前端工具函数
scripts/ 开发、构建和 smoke test 脚本
tests/ Bun test 测试
openspec/ OpenSpec 变更与规格文档
@@ -144,6 +147,8 @@ targets:
- `command`: 命令行拨测配置type 为 command 时必填)
- `exec`: 可执行文件名或路径
- `args`: 命令行参数列表
- `env`: 环境变量覆盖(可选,继承进程环境变量并合并覆盖)
- `cwd`: 工作目录(可选,相对于配置文件所在目录解析,默认 `.`
- `interval``timeout`: 覆盖全局默认值
- `expect`: 期望校验
- `status`: 可接受的状态码列表HTTP
@@ -170,7 +175,7 @@ targets:
| `GET /health` | 健康检查 |
| `GET /api/summary` | 总览统计total/up/down/lastCheckTime |
| `GET /api/targets` | 目标列表及最新状态、分组和采样数据 |
| `GET /api/targets/:id/history?from=ISO&to=ISO&page=1` | 指定目标的拨测记录(时间范围 + 分页) |
| `GET /api/targets/:id/history?from=ISO&to=ISO&page=1&pageSize=20` | 指定目标的拨测记录(时间范围 + 分页) |
| `GET /api/targets/:id/trend?from=ISO&to=ISO` | 指定目标的按小时聚合趋势 |
### 响应字段
@@ -191,6 +196,20 @@ targets:
**HistoryResponse**: `items`CheckResult[])、`total``page``pageSize`
### 错误响应
API 错误返回 `ApiErrorResponse` 格式:
```json
{ "error": "描述信息", "status": 400 }
```
| 状态码 | 触发场景 |
|--------|---------|
| 400 | 参数格式错误(无效 ID、from/to 缺失或格式错误、page/pageSize 非正整数) |
| 404 | 目标不存在、API 路由未匹配 |
| 405 | 非 GET 方法请求 API 路由 |
## 代码质量
```bash