From a7a637b0c6cf34356a7758d9c73d92017fab1994 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Thu, 16 Jul 2026 15:16:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=A5=E5=BF=97=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=88=97=E6=98=BE=E7=A4=BA=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=80=8C=E4=B8=8D=E6=98=AF=20raw=20unix=20ti?= =?UTF-8?q?mestamp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: logs_view 持久化分支直接用 query_logs 返回的 dict list 当模板变量,但模板里 e.timestamp_local 是 LogEntry 类 的属性。普通 dict 没有这个属性,Jinja 的 if 条件里抛 UndefinedError 后静默走 else e.time 分支,显示原始 float 时间戳 1784184579.49。 修法: 在持久化分支把 page_items 包成 LogEntry 实例 (用 **r 展开),让 timestamp_local property 生效。 非持久化分支没这个问题,因为 get_parsed_logs() 内部 已经做了 LogEntry(**r) wrap。 --- app.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index ca9cbd2..36ff85d 100644 --- a/app.py +++ b/app.py @@ -986,8 +986,11 @@ def logs_view(): "limit": per_page, "offset": (page - 1) * per_page, }) + # Wrap as LogEntry so the template's e.timestamp_local property + # works (query_logs returns plain dicts, which would otherwise + # silently fall through to the e.time branch in Jinja). + entries = [log_parser.LogEntry(**r) for r in page_items] # query_logs returns newest-first, so no re-reverse needed - entries = page_items else: entries = get_parsed_logs() f = dict(base_filters)