ui: 事件列表条目带年月日 — 跨天事件可区分

跨多天的事件列表仅显示 HH:MM 无法区分日期。按钮标签加 MM-DD
前缀,摘要行加浅蓝 YYYY-MM-DD 前缀,摘要截断 26→30 字适配。
This commit is contained in:
ericwyuan
2026-08-20 23:50:31 +08:00
parent 6ecdffce04
commit f50f98e292

View File

@@ -521,11 +521,12 @@ if page == "🕒 事件时间轴":
unsafe_allow_html=True)
for ev in events:
ts = parse_ts(ev['event_start_time'])
time_label = ts.strftime('%H:%M') if ts else '--:--'
time_label = ts.strftime('%m-%d %H:%M') if ts else '--:--'
date_label = ts.strftime('%Y-%m-%d') if ts else ''
summary = (ev.get('global_summary') or '').strip()
if not summary:
summary = '暂无摘要'
summary_short = summary if len(summary) <= 26 else summary[:26] + ''
summary_short = summary if len(summary) <= 30 else summary[:30] + ''
is_selected = ev['event_id'] == selected_id
if st.button(
f"{'' if is_selected else ''}{time_label} · {ev.get('camera_name') or '未知'} · {ev['detail_count']}",
@@ -535,9 +536,11 @@ if page == "🕒 事件时间轴":
):
st.session_state.selected_event_id = ev['event_id']
st.rerun()
date_html = (f'<span style="color:#7dd3fc;font-weight:600;">{date_label}</span> · '
if date_label else '')
st.markdown(
f'<div style="font-size:11px;color:#64748b;margin:-4px 2px 12px 2px;'
f'line-height:1.5;">{esc(summary_short)}</div>',
f'line-height:1.5;">{date_html}{esc(summary_short)}</div>',
unsafe_allow_html=True)
# 分页