# 监测槽:时长分钟档 + 指标进度条 + 负载 **日期**: 2026-06-12 ## 变更摘要 - 监测槽时长改为分钟粒度:30分 / 1时 / 2时 / 8时 / 24时,**默认 30 分钟** - 槽卡 UI:chip 选择时长;CPU / 内存 / 硬盘 百分比进度条;负载展示 1 分钟平均(与宝塔「负载」同源) - 后端 `watch_pins.ttl_minutes` 列;API 字段 `ttl_minutes`;兼容旧 `ttl_hours` 迁移 ## 动机 用户需要更细粒度默认监测窗口,并在槽位卡片上直观看到资源占用与系统负载。 ## 涉及文件 - `server/utils/watch_metrics.py` — TTL 分钟常量与归一化 - `server/domain/models/__init__.py` — `ttl_minutes` 列 - `server/infrastructure/database/migrations.py` — 迁移与回填 - `server/infrastructure/database/watch_repo.py` - `server/application/services/watch_service.py` - `server/api/watch.py` - `frontend/src/constants/watchTtl.ts` - `frontend/src/components/watch/WatchMetricBar.vue` - `frontend/src/components/watch/WatchSlotCard.vue` - `frontend/src/utils/watchFormat.ts` - `frontend/src/composables/useWatchPins.ts` - `tests/test_watch_pins.py`, `tests/test_watch_metrics.py` ## 迁移 / 重启 - 需 API 重启以执行 DB 迁移(`ttl_minutes` 列) - 前端需 `vite build` 后部署 ## 验证方式 ```bash pytest tests/test_watch_*.py -q cd frontend && npm run type-check bash scripts/local_verify.sh ``` 浏览器:监测槽选 30 分默认、切换时长、进度条与负载 chip 显示正常。 ## 补充(进度条阈值) - CPU/内存/硬盘进度条:≥90% 红、70–89% 黄、<70% 绿(`WatchMetricBar.vue`)。