Peach: Local-first video metadata scraper and media manager.
fix(web): 详情标签悬停有反馈,剧照按人脸取景,头像圈不再被削平
longmeidaoe23d9dfc2b32
diff --git a/.claude/skills/peach-jav-cover-workflow/SKILL.md b/.claude/skills/peach-jav-cover-workflow/SKILL.mdindex f9e62c247..5ea6fd2c6 100644--- a/.claude/skills/peach-jav-cover-workflow/SKILL.md+++ b/.claude/skills/peach-jav-cover-workflow/SKILL.md@@ -3,8 +3,8 @@ name: peach-jav-cover-workflowdescription: 在用户说 JAV 封面、高清封面、缺封面、封面刮削、重探、来源比较或继续抓取时使用。----最后复核:2026-08-31-证据来源:`scripts/fetch_jav_covers.py`、`tests/test_jav_covers.py`、`docs/REUSE.md` 与 ABW-232 官方来源实测。+最后复核:2026-09-03+证据来源:`scripts/fetch_jav_covers.py`、`scripts/detect_cover_faces.py`、`tests/test_jav_covers.py`、`docs/REUSE.md` 与 ABW-232 官方来源实测。# JAV 封面获取流程@@ -48,6 +48,21 @@ description: 在用户说 JAV 封面、高清封面、缺封面、封面刮削- 单条网络异常写失败并换连接池,任务继续;确认无候选与瞬时失败分开记录。- `DiskGuard` 运行期守住系统盘;每条完成后重写可续跑日志。+## 取景 sidecar++新封面落盘后补算人脸,否则页面只能用写死的锚点:++```powershell+& .\.venv\Scripts\python.exe .\scripts\detect_cover_faces.py+```++- 已算过的默认跳过,`--redo` 才重算;954 张实测检出 885 张,未检出的页面居中。+- sidecar 的 `cx` 和 `cy` 都要留着。用哪个轴由容器比例决定:`object-fit:cover`+ 一次只裁一个轴,16:9 官方剧照在大图版式里裁的是横向,纵向锚点在那里不生效。+- 版式判据(1.2 / 1.65 两个分界)在脚本和 `web/app.js` 的 `COVER_FRAME` 里各有+ 一份,改一处必须改两处:对不上就会出现「脚本按封套丢掉左半边的脸、页面按剧照+ 用那张脸取景」。+## 正式批次先重探所有缺失,包括旧的确认落空:diff --git a/scripts/detect_cover_faces.py b/scripts/detect_cover_faces.pyindex 9457055ea..c5889e52a 100644--- a/scripts/detect_cover_faces.py+++ b/scripts/detect_cover_faces.py@@ -1,19 +1,19 @@#!/usr/bin/env python3# -*- coding: utf-8 -*--r"""给已落盘的封面算人脸位置,供 4:3 版式取景用。+r"""给已落盘的封面算人脸位置,供卡片取景用。-固定取景(右侧 53%、纵向 22%)在多数封套上够用,但人物在画面里的高低差别很大,-写死的纵向位置会把一部分作品裁掉下巴或留出大片空白。人脸只用来做**纵向微调**,-横向仍由版式决定——横向靠几何规则已经稳定,没必要交给检出结果。+写死的锚点在多数封套上够用,但人物在画面里的位置差别很大。`object-fit:cover`+一次只裁一个轴,所以两个轴都要算,用哪个交给页面按版式挑:-判据来自 46 张真实封面的实测:+- 双页封套在 16:9 容器里被纵向裁,纵向锚点决定会不会切掉下巴或留出大片空白;+ 横向仍由几何规则定死(正封贴着封套右边缘),不交给检出结果。+- 16:9 官方剧照在大图容器里被横向裁,整幅都是画面,没有「正封那一块」可推。+ 横向锚点不跟着人走的话,偏在一侧的人物会整个落到可见窗口外面。-- Haar 正脸检出 24/46。检出率不高,所以这是「锦上添花」而不是取景的前提,- 取不到就退回固定值。-- 21/24 个检出落在 x 68~90%、y 12~33%,正是长封套右侧正封上的人脸位置。-- 剩下 3 个是假阳性:`278GYAN-017` 检到 x=2.9%(封套最左的剧照拼贴),- `KAVR-428` 一张图检出 7 个框。所以**长封套上落在左半边的检出一律丢弃**——- 那必然是剧照区,不是正封。+判据来自 46 张真实封面的实测:检出集中在长封套右侧正封的人脸位置(x 68~90%、+y 12~33%);封套最左的剧照拼贴里也有真脸(`278GYAN-017`、`KAVR-428`),所以+**长封套上落在左半边的检出一律丢弃**——那是拼贴区,不是正封。剧照没有拼贴区,+不套这条。检出不是取景的前提,取不到就退回固定值。结果写成每张封面一个 sidecar(`<番号>.face.json`),不写单一索引文件:抓取器可能正在并发写同目录,单文件会互相覆盖。脚本可反复运行,已算过的默认跳过。@@ -37,6 +37,8 @@ from peach.face_detect import FaceDetector, FaceModelUnavailable#: 长封套的宽高比下限。低于它按竖版正封处理(整张就是正封,没有剧照区)。SLEEVE_RATIO_MIN = 1.2+#: 上限之外是 16:9 官方剧照。这个值和 `web/app.js` 的 `COVER_FRAME` 必须是同一个,+#: 否则脚本按封套丢掉左半边的脸,页面却拿这张图当剧照按人脸取景,两边对不上。SLEEVE_RATIO_MAX = 1.65#: 长封套上正封的起始横向位置。左边是剧照拼贴,检出必然是假阳性。FRONT_START = 0.468diff --git a/src/peach/web_state.py b/src/peach/web_state.pyindex 9774ca5f2..e72fb13e9 100644--- a/src/peach/web_state.py+++ b/src/peach/web_state.py@@ -211,7 +211,7 @@ class WebContract:return path if path.is_file() else Nonedef cover_index(self) -> dict[str, dict | None]:- """封面目录扫一遍的索引:casefold(归一番号) → 取景 `{"cy": …}` 或 None。+ """封面目录扫一遍的索引:casefold(归一番号) → 取景 `{"cx": …, "cy": …}` 或 None。卡片列表逐行问「有封面吗」「取景是多少」,一页 60 行就是 120+ 次 stat 加读文件;封面目录一次 scandir 就覆盖全部番号,结果走 `cached()` 的 TTL。@@ -238,13 +238,20 @@ class WebContract:@staticmethoddef _cover_focus(sidecar: str) -> dict | None:- """sidecar 里的人脸中心。没算过、读不出或没检出都是 None,页面退回固定取景。"""+ """sidecar 里的人脸中心。没算过、读不出或没检出都是 None,页面退回固定取景。++ 两个轴都给出去:哪个轴生效由容器和图片的宽高比决定,不由这里判断。+ 缺哪个键就不带哪个键,前端各自回落,不要拿另一个轴的值顶替。+ """try:with open(sidecar, encoding="utf-8") as handle:face = (json.load(handle) or {}).get("face")except (OSError, ValueError):return None- return {"cy": face["cy"]} if isinstance(face, dict) and "cy" in face else None+ if not isinstance(face, dict):+ return None+ focus = {axis: face[axis] for axis in ("cx", "cy") if axis in face}+ return focus or Nonedef has_cover(self, code: str | None) -> bool:key = normalise_code_key(code)@@ -253,10 +260,11 @@ class WebContract:return bool(key) and key.casefold() in self.cover_index()def cover_frame(self, code: str | None) -> dict | None:- """封面的取景提示:人脸中心。没算过或没检出就返回 None。+ """封面的取景提示:人脸中心的两个轴。没算过或没检出就返回 None。- 只用来做纵向微调,横向仍由版式决定——横向靠几何规则已经稳定。- 取不到时前端退回固定取景,不影响显示。+ 双页封套的横向锚点仍由版式决定(正封贴着右边缘,几何规则已经稳定),人脸+ 横向只用在 16:9 官方剧照上——那种图在大图容器里只会横向裁,写死的居中会把+ 偏在一侧的人整个切掉。取不到时前端退回固定取景,不影响显示。"""key = normalise_code_key(code)return self.cover_index().get(key.casefold()) if key else Nonediff --git a/tests/test_follow_web.py b/tests/test_follow_web.pyindex 9c3642dcb..80c972202 100644--- a/tests/test_follow_web.py+++ b/tests/test_follow_web.py@@ -2018,6 +2018,12 @@ class FollowWebSourceTests(unittest.TestCase):self.assertPageContains("followTagChip(item,tag,'button')")self.assertPageContains("item.detail_tags||item.tags||[]")self.assertPageContains(".followdetailtags .tg{max-width:none")+ # 标签是按钮,点下去按这个标签筛选,必须有悬停反馈。通用 `.tg:hover` 的填充和+ # 文字色被按类型着色那两条同权重规则压掉了,只能按标签自己那个类型色加深一档。+ self.assertPageContains(+ ".followdetailtags .tg:hover{border-color:color-mix(in srgb,var(--r34-tag) 68%,transparent)")+ self.assertPageContains(+ "background:color-mix(in srgb,var(--r34-tag) 18%,transparent);color:var(--ink)}")self.assertPageContains("const postedBy=item.author&&foldName(item.author)!==foldName(author)")self.assertPageContains("openFollowDetail(id);")self.assertNotIn('class="cardopenhit" href=', self.page)diff --git a/tests/test_rm_web.py b/tests/test_rm_web.pyindex 0338d2753..ced4faba3 100644--- a/tests/test_rm_web.py+++ b/tests/test_rm_web.py@@ -1455,18 +1455,31 @@ class JavModeAndCoverTests(unittest.TestCase):self.assertIsNone(self.contract.cover_path("ABW-232"))self.assertIsNone(self.contract.cover_path(None))- def test_cover_frame_reads_the_face_sidecar(self):+ def test_cover_frame_reads_both_axes_out_of_the_face_sidecar(self):+ """哪个轴生效由容器和图片的宽高比决定,数据层两个都得给出去。++ 16:9 官方剧照在大图容器里只会横向裁,横向锚点丢在这一层的话,页面就只能+ 退回写死的 50%,偏在一侧的人物整个落到可见窗口外面。+ """(self.covers / "ABW-232.jpg").write_bytes(b"x")(self.covers / "ABW-232.face.json").write_text('{"ratio":1.49,"face":{"cx":0.82,"cy":0.19}}', encoding="utf-8")- self.assertEqual(self.contract.cover_frame("ABW-232"), {"cy": 0.19})+ self.assertEqual(self.contract.cover_frame("ABW-232"),+ {"cx": 0.82, "cy": 0.19})++ def test_a_sidecar_with_only_one_axis_keeps_just_that_axis(self):+ """缺的那个轴不带键,页面各自回落;不能拿另一个轴的值顶替。"""+ (self.covers / "ABW-232.jpg").write_bytes(b"x")+ (self.covers / "ABW-232.face.json").write_text(+ '{"ratio":1.78,"face":{"cx":0.13}}', encoding="utf-8")+ self.assertEqual(self.contract.cover_frame("ABW-232"), {"cx": 0.13})def test_a_cover_without_a_sidecar_falls_back_silently(self):(self.covers / "ABW-232.jpg").write_bytes(b"x")self.assertIsNone(self.contract.cover_frame("ABW-232"))def test_a_sidecar_reporting_no_face_is_not_a_frame(self):- # 检出率约 48%,没检出是常态而不是错误——必须安静回落。+ # 954 张实测检出 885 张,没检出是少数但确实存在——必须安静回落。(self.covers / "ABW-232.jpg").write_bytes(b"x")(self.covers / "ABW-232.face.json").write_text('{"ratio":1.49,"face":null}', encoding="utf-8")diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex 59e86086c..ab97e3e79 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -1121,7 +1121,7 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains("const COVER_FRONT_RATIO=0.7;")self.assertPageContains("(jav&&layout==='big'?COVER_FRONT_RATIO:16/9)")self.assertPageContains('.poster.cover.front[data-frame="sleeve"]{object-position:100%')- self.assertPageContains("r>1.2&&r<1.65?'sleeve':'front'",+ self.assertPageContains("r>=1.65?'still':r>1.2?'sleeve':'front'","16:9 官方剧照不能当成双页封套裁到最右侧")# 判据是 `jav` 不是 `useCover`:缺封面的卡片也要拉长,用 16:9 预览图上下留黑边,# 否则一行里高矮混排会把网格撕成锯齿状。@@ -1129,6 +1129,19 @@ class WebUiSourceTests(unittest.TestCase):# 旧键要继续认,设置存在浏览器里,改名不能让用户的选择静默回落。self.assertPageContains("const JAV_LAYOUT_ALIASES={cover:'big',sleeve:'small'};")+ def test_wide_stills_frame_on_the_detected_face_instead_of_dead_centre(self):+ """16:9 官方剧照在大图容器里只会横向裁,横向锚点必须跟着人走。++ 整幅剧照都是画面,没有「正封那一块」可推到右边缘;写死的 50% 只取画面中段,+ 人偏在一侧就整个落到可见窗口外面。纵向锚点在这个容器里根本不生效——容器比+ 所有封面都竖,`object-fit:cover` 裁的是横向那一轴。+ """+ self.assertPageContains(+ '.poster.cover.front[data-frame="still"]{object-position:var(--cover-x,50%)')+ self.assertPageContains("f.cx!=null?`--cover-x:${Math.round(Math.min(1,Math.max(0,f.cx))*100)}%`")+ # 没检出的那些居中,不能因为多了一个轴就把它们裁到边上去。+ self.assertPageContains("--cover-x,50%")+def test_card_avatar_and_name_open_the_same_entity(self):"""同一张卡上的头像和名字必须指向同一个身份。@@ -2712,6 +2725,18 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains(".relatedpeople{display:flex;gap:14px;overflow-x:auto;padding-bottom:4px")self.assertPageContains("height:var(--filterH);margin:0 -16px;padding:9px 16px")+ def test_horizontal_avatar_rails_leave_room_for_the_hover_ring(self):+ """圆头像的悬停圈和选中圈是外扩 `box-shadow`,横滚容器会把它削平。++ `overflow-x:auto` 把计算后的 `overflow-y` 一起变成 auto,头像贴着容器上沿+ 时那一圈就被裁掉顶部。留 3px 上方余量再用等量负 margin 抵掉,位置不动。+ 这两行是同一个缺陷重犯过多次的地方,写成一条共用规则。+ """+ self.assertPageContains(".tier,.relatedpeople{padding-top:3px;margin-top:-3px}")+ # `.tier` 后面那条不能再用 padding 简写,否则把上面的余量清回 0。+ self.assertPageContains("scrollbar-width:none;padding-inline:16px;padding-bottom:8px")+ self.assertPageLacks("scrollbar-width:none;padding:0 16px 8px")+def test_every_home_navigation_restores_the_shared_facets(self):self.assertPageContains("function showHomeSurfaces()")self.assertPageContains("$('#tiers').style.display='';$('#tagbar').style.display=''")@@ -2779,6 +2804,9 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains('wrap.innerHTML=visible.map(t=>`<span class="detailtag">')self.assertPageLacks("<small>官方</small>")self.assertPageLacks(".detailtag.official{")+ # 左半边点下去是按这个标签筛选,和右边的删除键一样得有悬停反馈;+ # 它没有选中态,照孤立按钮的写法抬填充。+ self.assertPageContains(".detailtag .tagfilter:hover{background:var(--hover);color:var(--ink)}")self.assertPageContains("const byDisplay=new Map()")self.assertPageContains("foldName(t.k)===key&&foldName(previous.k)!==key")diff --git a/web/app.css b/web/app.cssindex 5744d63ca..94417073a 100644--- a/web/app.css+++ b/web/app.css@@ -129,6 +129,11 @@ button[aria-busy="true"],[role="button"][aria-busy="true"]{.tier,.tagbar,.srow,.nrow{scrollbar-width:none}.tier::-webkit-scrollbar,.tagbar::-webkit-scrollbar,.srow::-webkit-scrollbar,.nrow::-webkit-scrollbar{display:none}+/* 横滚容器的 overflow-x:auto 会把计算后的 overflow-y 一起变成 auto,圆头像贴着容器+ 上沿时,:hover 和选中态那圈外扩 box-shadow 就被削平。留 3px 上方余量再用等量负+ margin 抵掉,位置一点不动。头像圈被遮是同一个缺陷重犯多次,横向头像行统一走这+ 一条,不要再逐处补 padding。`.followauthors` 自带余量,不在此列。 */+.tier,.relatedpeople{padding-top:3px;margin-top:-3px}/* ── 顶栏:无侧栏,图占主导 ── */.top{position:sticky;top:0;z-index:70;display:flex;align-items:center;gap:12px;@@ -174,7 +179,8 @@ button[aria-busy="true"],[role="button"][aria-busy="true"]{.tiers{position:relative;z-index:1;padding:10px 0 8px;border-bottom:0;background:linear-gradient(180deg,color-mix(in srgb,var(--frost-light) 38%,transparent),transparent)}-.tier{display:flex;gap:14px;overflow-x:auto;scrollbar-width:none;padding:0 16px 8px;align-items:flex-start}+/* padding-top 归上面那条头像圈余量的规则管,这里不能用 padding 简写把它清掉。 */+.tier{display:flex;gap:14px;overflow-x:auto;scrollbar-width:none;padding-inline:16px;padding-bottom:8px;align-items:flex-start}.tier::-webkit-scrollbar{display:none}.tier:last-child{padding-bottom:2px}/* 一层:圆头像 */@@ -1520,6 +1526,9 @@ body.index-open #tiers,body.index-open #tagbar{display:none}background:color-mix(in srgb,var(--surface) 82%,var(--ground));overflow:hidden;min-height:30px}.detailtag button{border:0;background:transparent;color:var(--ink-2);cursor:pointer;height:28px}.detailtag .tagfilter{padding:3px 5px 3px 11px}.detailtag .tagremove{width:28px;padding:0;display:grid;place-items:center;color:var(--muted)}+/* 标签左半边点下去是按这个标签筛选,得和右边的删除键一样有悬停反馈;+ 它没有选中态,照孤立按钮的写法抬填充。 */+.detailtag .tagfilter:hover{background:var(--hover);color:var(--ink)}.detailtag .tagremove:hover{color:var(--drop);background:color-mix(in srgb,var(--drop) 12%,transparent)}.detailtag svg,.tagplus svg{width:15px;height:15px;stroke:currentColor;fill:none;stroke-width:2}.tagplus{width:30px;height:30px;border:1px dashed var(--line);border-radius:50%;display:grid;place-items:center;@@ -2027,13 +2036,18 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位.pcheck input:disabled+span{cursor:not-allowed;opacity:.55}.pcheck:has(input:disabled){cursor:not-allowed}.pcheck:has(input:disabled)>span{background:var(--ground)}-/* 取景:正封模式下,整张封套要把镜头推到右半边;本身就是竖版正封的则整张用。+/* 取景:正封模式下,整张封套要把镜头推到右半边;本身就是竖版正封的则整张用;+ 16:9 官方剧照没有「正封那一块」,只能按人脸取。判据是图片自己的宽高比,由 onload 写进 data-frame。 */.poster.cover{width:100%;height:100%;object-fit:cover;display:block}-/* --cover-y 由人脸检出写入;没检出时回落到 22%,那是 46 张实测里的常见位置。 */+/* --cover-x / --cover-y 都由人脸检出写入。哪个轴生效取决于容器和图片谁更竖:+ `object-fit:cover` 只裁一个轴,另一个轴的锚点是死值。 *//* 右侧正封贴着封套右边缘,横向锚点就取最右;容器比例已经把可见窗口收成正封那一块。 */.poster.cover.front[data-frame="sleeve"]{object-position:100% var(--cover-y,22%)}.poster.cover.front[data-frame="front"]{object-position:50% var(--cover-y,22%)}+/* 剧照比大图容器宽得多,裁的是横向,所以横向锚点必须跟着人走。没检出时回落+ 居中:那是取不到人脸时唯一站得住的猜测。 */+.poster.cover.front[data-frame="still"]{object-position:var(--cover-x,50%) var(--cover-y,22%)}.poster.cover.whole{object-fit:contain;background:#000;object-position:50% 50%}@@ -2134,7 +2148,11 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位.followdetailplaceholder{display:grid;place-items:center;gap:10px;color:var(--muted)}.followdetailplaceholder .ficon{width:34px;height:34px;margin:0}.followdetailtitle{display:flex;gap:5px;align-items:flex-start;margin-bottom:8px}.followdetailtitle .stitle{width:auto;max-width:calc(100% - 35px);margin:0}.followdetailtitle .followorigin{flex:none;width:30px;height:30px;margin:0;display:grid;place-items:center;border-radius:var(--control-radius)}.followdetailtitle .followorigin:hover{background:var(--hover)}.followdetailidentity{display:flex;align-items:center;gap:10px;margin:2px 0 12px}.followdetailidentity .mav{flex:none}.followdetailidentity b,.followdetailidentity span{display:block}.followdetailidentity>div>span{margin-top:3px;color:var(--muted);font-size:var(--fs-xs)}-.followdetailsummary{margin:0 0 16px;line-height:1.6;color:var(--ink-2);white-space:pre-line}.followdetailtags .tg{max-width:none;overflow:visible;text-overflow:clip;white-space:normal;text-align:left;color:var(--ink-2);font-family:inherit}.followqueue .mixitempic>.fnothumb{position:static;width:100%;height:100%}+.followdetailsummary{margin:0 0 16px;line-height:1.6;color:var(--ink-2);white-space:pre-line}.followdetailtags .tg{max-width:none;overflow:visible;text-overflow:clip;white-space:normal;text-align:left;color:var(--ink-2);font-family:inherit}/* 通用 `.tg:hover` 的填充和文字色被上面按类型着色的两条同权重规则压掉了,+ 悬停得按标签自己那个类型色加深,不能回到中性的 `--hover`。 */+.followdetailtags .tg:hover{border-color:color-mix(in srgb,var(--r34-tag) 68%,transparent);+ background:color-mix(in srgb,var(--r34-tag) 18%,transparent);color:var(--ink)}+.followqueue .mixitempic>.fnothumb{position:static;width:100%;height:100%}.fnote.followmediaissue{margin:18px 0 8px;color:var(--drop)}.followresources{display:flex;flex-wrap:wrap;gap:8px;margin:0 0 16px}.followresources a{display:inline-flex;align-items:center;gap:7px;height:34px;padding:0 11px;border:1px solid var(--border-15);border-radius:var(--control-radius);color:var(--ink-2);text-decoration:none}.followresources a:hover{background:var(--hover);color:var(--ink);text-decoration:none}.followresources svg{width:15px;height:15px;stroke:currentColor;fill:none}.followdetailactions{margin-top:2px}/* 标签沉到侧栏最后:来源站的标签动辄几十个,夹在正文和操作之间就得先滚过整片标签云才够得着「已看/忽略」。 */diff --git a/web/app.js b/web/app.jsindex 53e72f82a..233e23d65 100644--- a/web/app.js+++ b/web/app.js@@ -1402,12 +1402,14 @@ function facePos(f){:f&&f.axis==='y'?` style="object-position:50% ${f.pct}%"`:'';}-/* 官方封套有两种形态,实测过:整张封套约 1.48(左侧是剧照拼贴,右侧才是正封),- 竖版正封约 0.70(本身就是正封,没有左半边可裁)。所以取景不能写死「取右边」,- 得等图片加载后按它自己的宽高比分流——服务端没存这个比例,也不该为此再存一份。 */-/* 常见双页 DVD 封套约 1.45:1;16:9 的横版官方剧照不是封套,不能把它也推到- 最右半边。上限给扫描留余量,但明确排除 259LUXU-1573 这类 1.78:1 剧照。 */-const COVER_FRAME=`onload="const r=this.naturalWidth/this.naturalHeight;this.dataset.frame=r>1.2&&r<1.65?'sleeve':'front'"`;+/* 官方封面有三种形态,实测过:整张封套约 1.48(左侧是剧照拼贴,右侧才是正封),+ 竖版正封约 0.70(本身就是正封,没有左半边可裁),16:9 官方剧照约 1.78(整幅+ 都是画面,没有「正封那一块」可推)。所以取景不能写死「取右边」,得等图片加载后+ 按它自己的宽高比分流——服务端没存这个比例,也不该为此再存一份。+ 剧照必须自成一档:把 1.78 归进 front 就会按写死的 50% 取横向中段,人偏在一侧+ 就整个被切掉,而大图容器比所有封面都竖、纵向锚点在那里根本不生效。 */+const COVER_FRAME=`onload="const r=this.naturalWidth/this.naturalHeight;`+ +`this.dataset.frame=r>=1.65?'still':r>1.2?'sleeve':'front'"`;/* 整张封套里右侧正封占的宽高比。裁切靠的是容器比例而不是 CSS 裁剪:`object-fit:cover`只在容器比图片更「竖」时才会横向裁;容器一旦宽过 1.48 就变成纵向裁、整张封套原样铺满,「大图」于是只撑满画布而取不到右侧。 */@@ -1418,13 +1420,18 @@ const COVER_FRONT_RATIO=0.7;const PORTRAIT_RATIO=9/16;function coverImage(it,layout,eager){const src=`/cover?code=${encodeURIComponent(it.code||'')}`;- // 人脸只做纵向微调:人物在画面里的高低差别很大,写死的纵向位置会把一部分- // 作品裁掉下巴或留出大片空白。检出率约 48%,取不到就退回固定值。- const cy=it.cover_frame&&it.cover_frame.cy;- const y=cy!=null?`--cover-y:${Math.round(Math.min(0.6,Math.max(0.05,cy))*100)}%`:'';+ // 两个轴都写出去,哪个生效交给 CSS 按版式挑:纵向给 16:9 容器里的封套用,+ // 横向给大图容器里的 16:9 剧照用。人物在画面里的位置差别很大,写死的锚点会把+ // 一部分作品裁掉下巴或整个切出画外;取不到就退回固定值。+ const f=it.cover_frame||{};+ // 纵向夹在 5%–60%:再往下就只剩身体,那是检出跑偏而不是构图。横向不夹——+ // `object-position` 的语义保证锚点落在 0–1 之间时人脸一定还在可见窗口里。+ const vars=[+ f.cy!=null?`--cover-y:${Math.round(Math.min(0.6,Math.max(0.05,f.cy))*100)}%`:'',+ f.cx!=null?`--cover-x:${Math.round(Math.min(1,Math.max(0,f.cx))*100)}%`:''].filter(Boolean).join(';');// 小图看整张(含剧照拼贴),大图只取右侧正封。return `<img class="poster cover ${layout==='small'?'whole':'front'}" src="${src}"- alt="" loading="${eager?'eager':'lazy'}"${y?` style="${y}"`:''} ${COVER_FRAME} data-drop="self">`;+ alt="" loading="${eager?'eager':'lazy'}"${vars?` style="${vars}"`:''} ${COVER_FRAME} data-drop="self">`;}/* 卡片署名。版次队列要和「接着看」长得一样,就必须用同一份身份推导——各算各的迟早会在同名 creator/performer 那 35 组上分叉,同一条作品在两处指向两个实体。