Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 女优页头按内容区宽度排三栏,「出演期间」改叫「生涯」

longmeidao19e1eedcfda3
diff --git a/docs/adr/0069-performer-page-header-shows-five-facts-and-grouped-names.md b/docs/adr/0069-performer-page-header-shows-five-facts-and-grouped-names.md
index f876b49b8..74e04db29 100644
--- a/docs/adr/0069-performer-page-header-shows-five-facts-and-grouped-names.md
+++ b/docs/adr/0069-performer-page-header-shows-five-facts-and-grouped-names.md
@@ -14,8 +14,8 @@ ADR-0067 把 minnano-av 资料表落进了 `performer_profile`,当时写明「
## 决策
-**一、页头只展示五项**:生日与年龄、身材(身高、三围、罩杯)、出道(日期与片名)、出演期间、站上的标签。
-它们放在页头右侧的资料表里,宽屏下和身份信息之间隔一道竖线;900px 以下排到身份信息下面。
+**一、页头只展示五项**:生日与年龄、身材(身高、三围、罩杯)、出道(日期与片名)、生涯(出演年份,页上写「生涯」)、站上的标签。
+它们放在页头右侧的资料表里,宽屏下和身份信息之间隔一道竖线;内容区不到 900px 宽时排到身份信息下面(量的是内容区,侧栏展开时同一个窗口会窄两百多像素)。
血型、出身地、趣味、博客都在账本里,但不上页头。页头是用来认人的,这五项回答「她是谁、什么体型、
什么时候出道、还拍不拍」;再多几项,资料表会比身份信息高出一截,头像两侧留空。
取不到的项服务端不下发,页面也就不画那一格,不写「未取得」。
diff --git a/frontend/e2e/design.test.ts b/frontend/e2e/design.test.ts
index b321d7c5f..54e60b5ca 100644
--- a/frontend/e2e/design.test.ts
+++ b/frontend/e2e/design.test.ts
@@ -1740,14 +1740,18 @@ describe('设计决定', () => {
});
}
- for (const viewport of [DESKTOP, { name: 'wide', width: 1440, height: 900, mobile: false }, MOBILE]) {
+ // 1000px 窗口侧栏展开时内容区只剩七百来像素:三栏的判据量的是内容区,这一档要排成两层,
+ // 身份那一栏不能被资料表挤到只剩一个字宽。
+ for (const [viewport, stacked] of [[DESKTOP, false], [{ name: 'wide', width: 1440, height: 900, mobile: false }, false],
+ [{ name: 'mid', width: 1000, height: 900, mobile: false }, true], [MOBILE, true]] as const) {
it(`女优页头:宽屏资料表在身份信息右侧隔一道竖线,窄屏排到下面隔一道横线,整张卡不横向溢出(${viewport.name})`, { timeout: 60_000 }, async () => {
const opened = await openProfiledPerformer(browser, viewport);
try {
const geometry = await heroGeometry(opened.page);
- assert.deepEqual(geometry.labels, ['生日', '身材', '出道', '出演期间', '标签'], '资料表不是那五项');
+ assert.deepEqual(geometry.labels, ['生日', '身材', '出道', '生涯', '标签'], '资料表不是那五项');
assert.ok(geometry.facts && geometry.identity && geometry.hero, '页头缺了资料表');
- if (viewport.mobile) {
+ assert.ok(geometry.identity.right - geometry.identity.left >= 240, '身份那一栏被挤窄了');
+ if (stacked) {
assert.ok(geometry.facts.top >= geometry.identity.bottom - 0.5, '窄屏下资料表没有排到身份信息下面');
assert.deepEqual(geometry.rule, { left: '0px', top: '1px' }, '窄屏下资料表该用横线和身份信息隔开');
} else {
diff --git a/src/peach/performer_header.py b/src/peach/performer_header.py
index ebd69f293..33f23c513 100644
--- a/src/peach/performer_header.py
+++ b/src/peach/performer_header.py
@@ -1,7 +1,7 @@
"""女优页头要的两样东西:五项资料(`profile`)与按名义分组的别名(`name_groups`)(ADR-0069)。
资料取自 `performer_profile`(ADR-0067),这里只读不写。页头只给五项:生日与年龄、身材、
-出道、出演期间、站上的标签。血型、出身地、趣味这些在账本里,不上页头:页头是认人用的,
+出道、生涯(出演年份)、站上的标签。血型、出身地、趣味这些在账本里,不上页头:页头是认人用的,
一行放不下的东西放进去只会把这五项挤成两行。取不到的项不给,前端也就不画那一格,
不写「未取得」。
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index d73843656..a44782cd9 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -9581,7 +9581,7 @@ class WebUiSourceTests(unittest.TestCase):
"row('cake','生日',",
"row('ruler','身材',",
"row('flag','出道',",
- "row('calendar-range','出演期间',",
+ "row('calendar-range','生涯',",
"row('tags','标签',"):
self.assertPageContains(needle)
# 关注来源那几处问的就是「有没有更新」,转圈归它们;页面归 React 之后是 Remix 的
diff --git a/web/app.js b/web/app.js
index 21403e438..7743aba43 100644
--- a/web/app.js
+++ b/web/app.js
@@ -4902,7 +4902,7 @@ const ENTITY_FEED_WAIT_TRIES=40;
const entityFeedTip=on=>on
?'已订阅新作:库里还没有的新片排在资料卡下面。再点一下取消订阅。'
:'订阅新作:定时去 JavDB 查这位有没有出新片,库里还没有的排在资料卡下面。';
-/* 女优页头右侧的资料表(ADR-0069):生日、身材、出道、出演期间和站上的标签。服务端只下发
+/* 女优页头右侧的资料表(ADR-0069):生日、身材、出道、生涯和站上的标签。服务端只下发
有值的项,这里有哪项画哪项,一项都没有就不出这张表。出道片名常有四五十个字,单行截断,
全名放在 title 里。仍在活跃的写「至今」:服务端只给 `ongoing`,字归页面。 */
function entityFactsHtml(p){
@@ -4917,7 +4917,7 @@ function entityFactsHtml(p){
if(p.debut_date||p.debut_title)row('flag','出道',[p.debut_date&&num(p.debut_date),p.debut_title&&sub(esc(p.debut_title))]
.filter(Boolean).join(' '),p.debut_title?` class="clip" title="${esc(p.debut_title)}"`:'');
const active=p.active||{};
- if(active.from)row('calendar-range','出演期间',
+ if(active.from)row('calendar-range','生涯',
esc(`${active.from}${active.ongoing?' – 至今':active.to?` – ${active.to}`:''}`),' class="num"');
const tags=p.tags||[];
if(tags.length)row('tags','标签',factTagsHtml(tags),' class="facttags"');
@@ -4926,6 +4926,13 @@ function entityFactsHtml(p){
/* 标签那一格只列前几个,余下的收进「+N」,浮层里一次看全,和名字那一行的别名同一个做法:
标签多的人有十几个,全摊开会把资料表撑成三四行,头像那一栏跟着被拉高。只多出一个时
直接列出来:「+1」和那一个标签一样宽。字是服务端换好的 Peach 中文标签。 */
+/* 资料卡排不排三栏看 `#index` 自己有多宽(判据与原因见 07-entity.css 那条规则)。
+ 量的是常驻的内容区,骨架和画好的页头读同一个开关,换页时不跳一次。 */
+const HERO_WIDE_PX=900;
+function syncHeroWide([entry]){
+ $('#index').toggleAttribute('data-hero-wide',entry.contentRect.width>=HERO_WIDE_PX);
+}
+new ResizeObserver(syncHeroWide).observe($('#index'));
const FACT_TAGS_SHOWN=4;
function factTagsHtml(tags){
const face=tag=>`<span class="facttag">${esc(tag)}</span>`;
diff --git a/web/css/07-entity.css b/web/css/07-entity.css
index 48b27fc30..b8cfba10d 100644
--- a/web/css/07-entity.css
+++ b/web/css/07-entity.css
@@ -11,13 +11,18 @@
align-items:center;min-width:0}
.entityprofile>.entityportraitwrap{align-self:stretch;display:flex;align-items:center}
/* 女优有资料时多出第三栏:右边那张资料表(ADR-0069),和身份信息之间隔一道竖线。
- 宽 300–400px:生日、身材一行放得下,出道片名截断后还剩一半字。900px 以下它排到身份信息
- 下面,隔的线换成横的;760px 以下整张卡单列居中,表里仍左对齐,两列字才对得齐。 */
-@media(min-width:901px){.entityprofile:has(>.entityfacts){grid-template-columns:auto minmax(0,1fr) minmax(300px,400px)}}
+ 宽 280–360px:生日、身材一行放得下,出道片名截断后还剩一半字。
+ 三栏的判据是内容区的宽度,不是视口:侧栏展开时同一个窗口留给卡的宽度少两百多像素,
+ 按视口断点的话 1000px 的窗口里身份那一栏只剩 44px,名字竖着排。内容区不到 900px
+ (头像 160、两道间隔、资料表 360 之外身份栏还有 300)时它排到身份信息下面,隔的线换成
+ 横的;760px 以下整张卡单列居中,表里仍左对齐,两列字才对得齐。容器查询做不了这件事:
+ 它顺带的布局隔离会让卡里那几枚 fixed 定位的菜单和遮罩改以卡为基准,所以宽度由
+ `#index` 上的 `data-hero-wide` 带进来(`syncHeroWide`)。 */
+#index[data-hero-wide] .entityprofile:has(>.entityfacts){grid-template-columns:auto minmax(0,1fr) minmax(280px,360px)}
.entityfacts{margin:0;align-self:stretch;justify-self:stretch;align-content:center;display:grid;
grid-template-columns:auto minmax(0,1fr);gap:10px 16px;min-width:0;padding:2px 0 2px 24px;
border-left:1px solid var(--line-soft);font-size:var(--fs-sm);line-height:22px;text-align:left}
-@media(max-width:900px){.entityfacts{grid-column:1/-1;border-left:0;border-top:1px solid var(--line-soft);padding:14px 0 0}}
+#index:not([data-hero-wide]) .entityfacts{grid-column:1/-1;border-left:0;border-top:1px solid var(--line-soft);padding:14px 0 0}
.entityfacts dt{display:flex;align-items:center;align-self:start;gap:6px;color:var(--muted);white-space:nowrap}
.entityfacts dd{margin:0;min-width:0;color:var(--ink)}
.entityfacts .num{font-variant-numeric:tabular-nums}