7a0001d8f4
≥90% 红、70–89% 黄、<70% 绿。 Co-authored-by: Cursor <cursoragent@cursor.com>
1.6 KiB
1.6 KiB
监测槽:时长分钟档 + 指标进度条 + 负载
日期: 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.pyserver/application/services/watch_service.pyserver/api/watch.pyfrontend/src/constants/watchTtl.tsfrontend/src/components/watch/WatchMetricBar.vuefrontend/src/components/watch/WatchSlotCard.vuefrontend/src/utils/watchFormat.tsfrontend/src/composables/useWatchPins.tstests/test_watch_pins.py,tests/test_watch_metrics.py
迁移 / 重启
- 需 API 重启以执行 DB 迁移(
ttl_minutes列) - 前端需
vite build后部署
验证方式
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)。