feat(ui): 人物管理显示人物代表画面 - 每个身份取其一 label 出现事件的截图作为头像(Oracle event thumb 接口)

This commit is contained in:
ericwyuan
2026-08-21 14:03:43 +08:00
parent 3fcd00d4c8
commit 92ef9fe163

View File

@@ -802,13 +802,33 @@ elif page == "👤 人物管理":
f'border:1px solid #713f12;padding:1px 8px;border-radius:10px;'
f'margin-left:8px;">未命名</span>')
label_str = ' · '.join(g['labels'])
# 人物代表画面:取该身份任一 label 出现事件的截图(头像)
rep_img = ''
if _oracle_url:
for lb in g['labels']:
try:
cursor.execute(
"SELECT e.id FROM sync_events e WHERE e.person_list_json LIKE %s "
"ORDER BY e.id LIMIT 1", (f'%{lb}%',))
r2 = cursor.fetchone()
if r2 and r2['id']:
rep_img = (
f'<img src="{_oracle_url}/api/oracle/event/{r2["id"]}/thumb'
f'?token={_oracle_token}" '
f'style="width:140px;height:94px;object-fit:cover;border-radius:8px;'
f'border:1px solid #1e293b;margin:8px 0;" '
f'onerror="this.style.display=\'none\'"/>')
break
except Exception:
continue
st.markdown(
f'<div style="font-size:16px;font-weight:700;color:#f1f5f9;">'
f'{esc(key)}{tag}</div>'
f'<div style="font-size:12px;color:#8b93a7;margin-top:5px;line-height:1.6;">'
f'标识: {esc(label_str)}</div>'
f'<div style="font-size:11px;color:#64748b;margin-top:6px;">'
f'出现 <b style="color:#cbd5e1;">{g["appearances"]}</b> 次 · 首次 {esc(first_str)}</div>',
f'出现 <b style="color:#cbd5e1;">{g["appearances"]}</b> 次 · 首次 {esc(first_str)}</div>'
f'{rep_img}',
unsafe_allow_html=True)
if not is_named:
# 未命名身份:每个 label 都给一个命名框