fix(头像): 人物头像改为'出现事件画面'而非视频首帧 - 新增 /api/oracle/person/avatar(在该人物所有出现事件中返回第一个有截图的事件画面,JSON 精确匹配);撤销 event_thumb 的视频首帧兜底(首帧可能无人/非本人);fam-ui 人物页改调 avatar 接口

This commit is contained in:
ericwyuan
2026-08-21 16:13:05 +08:00
parent 27bfd6abbe
commit 2ba3478291
2 changed files with 36 additions and 20 deletions

View File

@@ -807,19 +807,21 @@ elif page == "👤 人物管理":
f'border:1px solid #713f12;padding:1px 8px;border-radius:10px;'
f'margin-left:8px;">未命名</span>')
label_str = ' · '.join(g['labels'])
# 人物代表画面:取该身份任一 label 出现事件的截图(头像)
# 人物代表画面:Oracle 端在该人物出现的所有事件中挑第一个有截图的事件画面
# (该人物在多个视频多次出现,肯定能找到出现时刻的画面,不用视频首帧冒充)
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']:
rp = requests.get(
f"{_oracle_url}/api/oracle/person/avatar",
params={"label": lb, "token": _oracle_token},
timeout=10)
if rp.status_code == 200:
import urllib.parse
rep_img = (
f'<img src="{_oracle_url}/api/oracle/event/{r2["id"]}/thumb'
f'?token={_oracle_token}" '
f'<img src="{_oracle_url}/api/oracle/person/avatar'
f'?label={urllib.parse.quote(lb)}&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\'"/>')