Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(web): 共演者那排圆头像按人脸取景,链接图标不再垫暗盘

longmeidaoa9eb9a97b61a
diff --git a/src/peach/web_entity.py b/src/peach/web_entity.py
index b169f1cb3..320c2eeb1 100644
--- a/src/peach/web_entity.py
+++ b/src/peach/web_entity.py
@@ -192,15 +192,15 @@ def q_entity(contract: WebContract, args):
# 都取不到就一个 `<img>` 都不出。判定在库连接之外做,它读的是目录索引。
d["has_image"] = contract.has_entity_image(kind, d["id"])
attach_avatar_availability(contract, [d], key="representative_asset_id")
- # 页脚那排共演者是同一个圆头像,用的也是同一条两级链。
+ # 页脚那排共演者是同一个圆头像,用的也是同一条两级链,取景也是同一份 sidecar。
+ # 圆框越小越需要取景:一张 3762×2535 的封面塞进 44 px 的圆里,几何居中给出的是
+ # 封面正中那块版式,脸在不在里面全看运气。事务所页的艺人大图与这排小圆头像用
+ # 同一条链,差别只在框多大,所以判据不该按页面分岔。
for person in d["related_performers"]:
person["has_image"] = contract.has_entity_image("performer", person["id"])
+ person["avatar_focus"] = contract.avatar_focus("performer", person["id"])
attach_avatar_availability(contract, d["related_performers"])
if kind == "agency":
- # 事务所页默认摆的是艺人大图,那个版式把头像裁成竖幅,几何居中会切掉脸。
- # 取景与索引页大图同一份 sidecar、同一个换算,别的页面那排小圆头像用不上。
- for person in d["related_performers"]:
- person["avatar_focus"] = contract.avatar_focus("performer", person["id"])
# 事务所的门面是它自己的标识。没装实体图时给出官网那条链接的 id,页面拿它去
# `/link-mark` 取站点圆标;两样都没有就只剩首字母。作品截图不参加——那是
# 某位成员某部片的画面,和这家公司没有关系。
diff --git a/tests/test_rm_web.py b/tests/test_rm_web.py
index 8529f2de3..9363b15a8 100644
--- a/tests/test_rm_web.py
+++ b/tests/test_rm_web.py
@@ -1305,6 +1305,9 @@ class WebDataTests(unittest.TestCase):
self.assertEqual(page["tags"], [{"id": 10, "k": "足交", "n": 1}])
self.assertEqual(page["related_performers"][0]["k"], "Related Bob")
self.assertEqual(page["related_performers"][0]["n"], 1)
+ # 那排共演者是同一条两级取图链,取景也走同一份 sidecar。键必须在:没算过时
+ # 是 None,页面据此维持几何居中,而键缺席会让页面读到 undefined。
+ self.assertIn("avatar_focus", page["related_performers"][0])
self.assertTrue(page["links"][0]["clickable"])
self.assertFalse(page["links"][1]["clickable"])
self.assertIsNone(page["links"][1]["url"])
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 68bc978b3..daed5dfa0 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -1441,6 +1441,13 @@ class WebUiSourceTests(unittest.TestCase):
# 填充字形不吃通用的 stroke:currentColor;fill:none。
self.assertPageContains('.entitylinkicon.brand svg{width:15px;height:15px;fill:currentColor;stroke:none}')
+ def test_the_link_icon_disc_carries_no_plate_of_its_own(self):
+ """内联品牌标记直接画在药丸上。垫一层 `--sunk` 会让它比周围暗一档,看着像
+ 这条链接被禁用了——而图标要说的是「去哪」,不是「能不能点」。"""
+ self.assertPageContains(
+ ".entitylinkicon{width:32px;height:32px;border-radius:50%;"
+ "background:transparent;")
+
def test_the_entity_hero_is_a_centred_single_column_on_phones(self):
# 左像右文那套是给宽屏的:手机上 92px 头像旁边只剩两百多像素,别名和链接被挤成
# 两三行,头像下面又空着一大片。按 beeg 的资料页改成单列居中。
@@ -4440,6 +4447,12 @@ class WebUiSourceTests(unittest.TestCase):
# 名册占的是正文那一整块,所以这批人不再挤进「同台艺人」那排小圆头像。
self.assertCode("const roster=kind==='agency'?(d.related_performers||[]):[];")
self.assertCode("const related=roster.length?'':(d.related_performers||[]).map(")
+ # 圆框越小越需要取景:一张 3762×2535 的封面塞进 44px 的圆里,几何居中给出的是
+ # 封面正中那块版式,脸在不在里面全看运气。
+ self.assertPageContains(
+ "{id:x.id,hasImage:x.has_image,rep:x.has_avatar?x.rep:null,")
+ self.assertPageContains(
+ " style:facePos(x.avatar_focus),focus:x.avatar_focus})}</span>")
def test_a_company_cell_is_square_because_it_holds_a_mark_not_a_face(self):
"""3:4 是给脸留的形状,方标铺进去左右各被 `object-fit:cover` 裁掉四分之一。"""
diff --git a/web/app.js b/web/app.js
index 0b012b78f..18f59103e 100644
--- a/web/app.js
+++ b/web/app.js
@@ -6310,7 +6310,8 @@ async function openEntity(kind,name,push=true){
agencyRoster=roster;
const related=roster.length?'':(d.related_performers||[]).map(x=>`<button class="relatedperson" data-related-performer="${esc(x.k)}">
<span class="ring"><span>${esc(x.k.slice(0,1))}</span>${entityFaceImg(
- {id:x.id,hasImage:x.has_image,rep:x.has_avatar?x.rep:null})}</span>
+ {id:x.id,hasImage:x.has_image,rep:x.has_avatar?x.rep:null,
+ style:facePos(x.avatar_focus),focus:x.avatar_focus})}</span>
<span class="nm">${esc(x.k)}</span></button>`).join('');
const photoCount=photos&&!photos.error?(photos.total||0):0;
/* 艺人名册和视频、照片是这一页的三个互斥视图,共用一组按钮:它们回答的是同一个
diff --git a/web/css/07-entity.css b/web/css/07-entity.css
index 4c5bc6ee3..7bf50551a 100644
--- a/web/css/07-entity.css
+++ b/web/css/07-entity.css
@@ -41,7 +41,9 @@
background:var(--overlay-5);display:inline-flex;align-items:center;gap:8px;overflow:hidden}
.entitylinks a:hover{border-color:var(--border-15);background:var(--hover)}
.entitylinks .private{color:var(--muted);border-style:dashed}
-.entitylinkicon{width:32px;height:32px;border-radius:50%;background:var(--sunk);display:grid;place-items:center;
+/* 圆盘本身不垫底色。X 这类内联品牌标记直接画在药丸上,垫一层 `--sunk` 只会让它比
+ 周围暗一档,看着像这条链接被禁用了——而图标要说的是「去哪」,不是「能不能点」。 */
+.entitylinkicon{width:32px;height:32px;border-radius:50%;background:transparent;display:grid;place-items:center;
overflow:hidden;position:relative;flex:none}.entitylinkicon svg{width:16px;height:16px;stroke:currentColor;fill:none;
stroke-width:1.8}
/* favicon 是别人服务器上的位图,取不到时 `onerror` 会把 img 摘掉、露出下面的地球。