fix: 日志查询时间列显示本地时间而不是 raw unix timestamp

根因: 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。
This commit is contained in:
Hermes Agent
2026-07-16 15:16:17 +08:00
parent 0d413cfeaf
commit a7a637b0c6
+4 -1
View File
@@ -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)