abeab9d3e4
Store alert metrics without per-value Redis members to stop duplicate recovery pushes; format all operator-facing timestamps in Asia/Shanghai across Web UI and Telegram.
1.5 KiB
1.5 KiB
2026-06-08 — 全站用户可见时间统一为北京时间
变更摘要
存储与计算仍用 UTC;所有面向运维的展示层(Web 表格、Telegram、设置页刷新时间等)统一为 Asia/Shanghai 北京时间。
动机
用户要求不论浏览器时区,界面与通知时间与国内运维习惯一致。
方案
- 后端:
server/utils/display_time.py(format_beijing/format_beijing_now);Telegram、IP 白名单刷新时间、Telegram 测试消息接入 - 前端:
frontend/src/utils/datetime.ts(parseApiDateTime将 MySQL naive UTC 正确解析 +formatDateTimeBeijing等);15 页相关表格/内联详情/WS 告警条改用该工具
涉及文件
server/utils/display_time.py(新)server/infrastructure/telegram/__init__.pyserver/background/ip_allowlist_refresh.pyserver/api/settings.pyfrontend/src/utils/datetime.ts(新)frontend/src/utils/status.tsfrontend/src/composables/push/labels.tsfrontend/src/composables/useWebSocket.ts- 多页 Vue:
AlertsAuditCommandsRetriesSchedulesScriptsScriptRunsServers及凭据/子机内联组件
迁移 / 重启
- 无 DB 迁移
- 需重新构建前端并重启 API
验证方式
.venv/bin/python -m pytest tests/test_display_time.py tests/test_telegram_time_format.py tests/test_agent_recovery_dedup.py -q
cd frontend && npm run type-check
浏览器:告警历史、审计、推送历史等列时间应为北京时间(与 UTC 差 8 小时)。