Files
Nexus/docs/changelog/2026-06-08-beijing-time-display-unified.md
T

41 lines
1.5 KiB
Markdown
Raw Normal View History

# 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__.py`
- `server/background/ip_allowlist_refresh.py`
- `server/api/settings.py`
- `frontend/src/utils/datetime.ts`(新)
- `frontend/src/utils/status.ts`
- `frontend/src/composables/push/labels.ts`
- `frontend/src/composables/useWebSocket.ts`
- 多页 Vue`Alerts` `Audit` `Commands` `Retries` `Schedules` `Scripts` `ScriptRuns` `Servers` 及凭据/子机内联组件
## 迁移 / 重启
- 无 DB 迁移
- 需重新构建前端并重启 API
## 验证方式
```bash
.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 小时)。