Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): unify compact card heights

longmeidao35d72da48ba4
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 2f1712a26..5392102cf 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -186,21 +186,23 @@ class WebUiSourceTests(unittest.TestCase):
# 多人合集保留头像提示,但文字只写第一位和总人数,避免名称折成多行。
self.assertPageContains("const coStarred=performers.length>1&&!primaryCreator")
self.assertPageContains('<div class="mavstack">')
- self.assertPageContains("performers.slice(0,smallLayout?2:3)")
+ self.assertPageContains("performers.slice(0,3)")
self.assertPageContains("data-entity-kind=\"performer\" data-entity-name=\"${esc(nm)}\"")
self.assertPageContains("data-entity-name=\"${esc(performer)}\"")
self.assertPageContains("等 ${performerTotal} 人")
self.assertPageContains(".mavstack .mav+.mav{margin-left:-14px}")
- def test_jav_small_cards_use_three_fixed_rows_for_every_item_on_the_page(self):
- # 小图是页面版式:混入的非番号作品也必须保持标题、身份、标签三行同高。
- self.assertPageContains("const smallLayout=javActive()&&layout==='small'")
- self.assertPageContains("${smallLayout?'jav-small ':''}")
- self.assertPageContains(".jav-small .mtext{display:grid;grid-template-rows:1.35em 1.35em 30px")
- self.assertPageContains(".jav-small .meta .t{display:block;max-width:100%;min-height:1.35em;white-space:nowrap;text-overflow:ellipsis;")
- self.assertPageContains(".jav-small .meta .s{min-height:1.35em;flex-wrap:nowrap;overflow:hidden;white-space:nowrap}")
- self.assertPageContains(".jav-small .ctags{height:30px;align-items:flex-start;flex-wrap:nowrap;overflow:hidden}")
- self.assertPageContains(".jav-small .meta .why,.jav-small .meta .watchcount{display:none}")
+ def test_dense_cards_use_three_fixed_rows_without_changing_jav_metadata_height(self):
+ # 顶栏密集模式固定标题、身份、标签三行;JAV 小图和预览图只换图片来源,
+ # 不再给其中一种额外加一行高度。
+ self.assertPageContains('body[data-density="dense"] .grid>.card{padding-top:7px}')
+ self.assertPageContains('body[data-density="dense"] .card .mtext{display:grid;grid-template-rows:1.35em 1.35em 30px;')
+ self.assertPageContains('gap:3px;height:calc(2.7em + 36px);overflow:hidden}')
+ self.assertPageContains('body[data-density="dense"] .card .meta .s{height:1.35em;min-height:0;flex-wrap:nowrap;overflow:hidden;white-space:nowrap}')
+ self.assertPageContains('body[data-density="dense"] .card .ctags{height:30px;align-items:flex-start;flex-wrap:nowrap;overflow:hidden}')
+ self.assertPageContains('body[data-density="dense"] .card .meta .watchcount{display:none}')
+ self.assertPageContains('小图与预览图都是 16:9 横图,只更换图片来源;元数据 DOM 和高度必须完全相同。')
+ self.assertPageLacks("jav-small")
self.assertPageContains('<span class="watchcount">看过 ${it.play_count}</span>')
def test_every_card_avatar_falls_back_through_the_same_helper(self):
@@ -755,7 +757,8 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("loadRequestSeq++;listLoading=false;$('#combo').innerHTML=''")
def test_sidebar_add_controls_have_one_explicit_height(self):
- self.assertPageContains(".sidebaradd .sidebaraddfield{display:grid;grid-template-columns:auto minmax(0,1fr) auto;width:100%;height:42px")
+ self.assertPageContains(".sidebaradd .sidebaraddfield{display:grid;grid-template-columns:auto minmax(0,1fr) auto;width:100%;height:42px;box-sizing:border-box;align-items:center;justify-items:start")
+ self.assertPageContains(".sidebaraddfield svg:last-child{justify-self:end;color:var(--muted)}")
self.assertPageContains(".sidebaradd>button{height:42px;box-sizing:border-box}")
def test_edge_and_drawer_share_one_navigation_dispatch(self):
@@ -1639,7 +1642,7 @@ class WebUiSourceTests(unittest.TestCase):
".entitytags button", ".fauthor .fsource.frow>b", ".fauthorhead b",
".fchip", ".folderfoot .fmeta", ".fpickactions [data-pick-state]",
".frow>b", ".fvkind", ".idname", ".kv>span:first-child",
- ".jav-small .meta .t", ".meta .t", ".meta .who", ".mixcopy b,.mixcopy span",
+ ".meta .t", ".meta .who", ".mixcopy b,.mixcopy span",
".mixitemtext [data-truncate-end]", ".mixqueuehead h2",
".playerstats dd", ".relatedperson .nm", ".reviewentity b",
".reviewitem h4", ".searchoption span",
diff --git a/web/app.css b/web/app.css
index ccffb3c19..44ca0ef87 100644
--- a/web/app.css
+++ b/web/app.css
@@ -807,18 +807,21 @@ body.select-mode .selectionMark,.card.selected .selectionMark{display:grid}
.tg:hover{border-color:var(--ink-2);color:var(--ink);background:var(--hover)}
body[data-density="dense"] .card .ctags .tg:nth-child(n+2){display:none}
body[data-density="dense"] .card .ctags .tg{max-width:132px;overflow:hidden;text-overflow:ellipsis}
+/* 顶栏的密集模式固定为标题、身份、标签三行。缺少标签时第三行仍保留,
+ 同一网格不会再被大小、观看次数或长身份撑成四行。分卷卡已有 7px 叠层空间,
+ 密集网格的普通卡也保留同一高度,避免每行是否出现分卷卡决定整行高度。 */
+body[data-density="dense"] .grid>.card{padding-top:7px}
+body[data-density="dense"] .card .mtext{display:grid;grid-template-rows:1.35em 1.35em 30px;
+ gap:3px;height:calc(2.7em + 36px);overflow:hidden}
body[data-density="dense"] .card .meta .t{display:block;max-width:100%;min-height:1.35em;overflow:hidden;
-webkit-line-clamp:unset;white-space:nowrap;text-overflow:ellipsis}
-/* JAV 小图固定为标题、身份、标签三行;整页的混合卡片都遵守同一高度,超长内容逐行省略。 */
-.jav-small .mtext{display:grid;grid-template-rows:1.35em 1.35em 30px;gap:3px;min-height:calc(2.7em + 36px)}
-.jav-small .meta .t{display:block;max-width:100%;min-height:1.35em;white-space:nowrap;text-overflow:ellipsis;
- -webkit-line-clamp:unset}
-.jav-small .meta .s{min-height:1.35em;flex-wrap:nowrap;overflow:hidden;white-space:nowrap}
-.jav-small .meta .who{flex:0 1 auto}
-.jav-small .meta .whomore{flex:none;white-space:nowrap}
-.jav-small .meta .size{flex:none;white-space:nowrap}
-.jav-small .ctags{height:30px;align-items:flex-start;flex-wrap:nowrap;overflow:hidden}
-.jav-small .meta .why,.jav-small .meta .watchcount{display:none}
+body[data-density="dense"] .card .meta .s{height:1.35em;min-height:0;flex-wrap:nowrap;overflow:hidden;white-space:nowrap}
+body[data-density="dense"] .card .meta .who{flex:0 1 auto}
+body[data-density="dense"] .card .meta .whomore,
+body[data-density="dense"] .card .meta .size{flex:none;white-space:nowrap}
+body[data-density="dense"] .card .ctags{height:30px;align-items:flex-start;flex-wrap:nowrap;overflow:hidden}
+body[data-density="dense"] .card .meta .why,
+body[data-density="dense"] .card .meta .watchcount{display:none}
/* 短片带 */
.shorts{margin:30px 0 8px;border-top:1px solid var(--line-soft);padding-top:16px}
@@ -1073,7 +1076,7 @@ body.settings-open{overflow:hidden}
#censorSetting:checked::after{left:17px}
#censorSetting:focus-visible{outline:2px solid var(--tungsten);outline-offset:2px}
.sidebarsetting{display:grid;gap:12px;padding:0}.sidebarsetting>span b,.sidebarsetting>span small{display:block}.sidebarsetting>span small{margin-top:3px;color:var(--muted);line-height:1.45}.sidebarorder{display:grid;gap:6px}.sidebarorderrow{position:relative;display:flex;align-items:center;justify-content:space-between;min-height:48px;padding:5px 6px;border:1px solid var(--line-soft);border-radius:9px;background:var(--overlay-3);cursor:grab}.sidebarorderrow:active{cursor:grabbing}.sidebarorderrow.dragging{opacity:.42}.sidebarorderrow.drop-before::before,.sidebarorderrow.drop-after::after{content:'';position:absolute;z-index:2;left:7px;right:7px;height:2px;border-radius:2px;background:var(--tungsten)}.sidebarorderrow.drop-before::before{top:-5px}.sidebarorderrow.drop-after::after{bottom:-5px}.sidebarorderrow>span{display:flex;align-items:center;gap:8px}.sidebarorderrow svg{width:18px;height:18px;stroke:currentColor;fill:none}.sidebarorderlabel{min-width:0}.sidebarorderlabel>b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sidebardrag{display:grid;place-items:center;width:24px;color:var(--muted)}.sidebardrag svg{width:20px;height:20px}.sidebarorderactions{flex:none}.sidebarorderrow button,.sidebaradd button{display:grid;place-items:center;min-width:34px;height:34px;border:0;border-radius:7px;background:transparent;color:var(--muted);cursor:pointer}.sidebarorderrow button:hover:not(:disabled),.sidebaradd button:hover:not(:disabled){background:var(--hover);color:var(--ink)}.sidebarorderrow button:disabled,.sidebaradd button:disabled{opacity:.25;cursor:default}.sidebaradd{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;margin-top:5px}
-.sidebaraddpicker{position:relative;min-width:0}.sidebaradd .sidebaraddfield{display:grid;grid-template-columns:auto minmax(0,1fr) auto;width:100%;height:42px;box-sizing:border-box;align-items:center;gap:9px;padding:0 11px;border:1px solid var(--line);border-radius:8px;background:#181a1d;color:#f5f7fa;text-align:left;font:inherit}.sidebaraddfield svg:last-child{color:var(--muted)}.sidebaraddmenu{position:absolute;z-index:4;left:0;right:0;bottom:calc(100% + 6px);max-height:min(312px,48vh);overflow:auto;overscroll-behavior:contain;padding:6px;border:1px solid var(--border-15);border-radius:10px;background:#181a1d;box-shadow:0 16px 44px -20px #000}.sidebaraddmenu[hidden]{display:none}.sidebaradd .sidebaraddmenu button{grid-template-columns:auto minmax(0,1fr);width:100%;height:38px;justify-content:start;gap:9px;padding:0 8px;border:0;text-align:left}.sidebaraddmenu button[aria-selected="true"]{background:var(--hover);color:var(--ink)}.sidebaradd button{grid-template-columns:auto auto;gap:6px;padding:0 11px;border:1px solid var(--line);color:var(--ink-2)}.sidebaradd svg{width:17px;height:17px;stroke:currentColor;fill:none}
+.sidebaraddpicker{position:relative;min-width:0}.sidebaradd .sidebaraddfield{display:grid;grid-template-columns:auto minmax(0,1fr) auto;width:100%;height:42px;box-sizing:border-box;align-items:center;justify-items:start;gap:9px;padding:0 11px;border:1px solid var(--line);border-radius:8px;background:#181a1d;color:#f5f7fa;text-align:left;font:inherit}.sidebaraddfield svg:last-child{justify-self:end;color:var(--muted)}.sidebaraddmenu{position:absolute;z-index:4;left:0;right:0;bottom:calc(100% + 6px);max-height:min(312px,48vh);overflow:auto;overscroll-behavior:contain;padding:6px;border:1px solid var(--border-15);border-radius:10px;background:#181a1d;box-shadow:0 16px 44px -20px #000}.sidebaraddmenu[hidden]{display:none}.sidebaradd .sidebaraddmenu button{grid-template-columns:auto minmax(0,1fr);width:100%;height:38px;justify-content:start;gap:9px;padding:0 8px;border:0;text-align:left}.sidebaraddmenu button[aria-selected="true"]{background:var(--hover);color:var(--ink)}.sidebaradd button{grid-template-columns:auto auto;gap:6px;padding:0 11px;border:1px solid var(--line);color:var(--ink-2)}.sidebaradd svg{width:17px;height:17px;stroke:currentColor;fill:none}
.sidebaradd>button{height:42px;box-sizing:border-box}@media(max-width:600px){.settingsscroll{padding:0 17px 17px}.settingshead{padding:17px 17px 14px}.settingrow{grid-template-columns:1fr;gap:9px}.settingrow select{width:100%;min-width:0}.settingrow input[type=checkbox]{justify-self:start}}
.sidebaradd .sidebaraddmenu button{justify-items:start}
diff --git a/web/app.js b/web/app.js
index 10585fe40..049fb2ba6 100644
--- a/web/app.js
+++ b/web/app.js
@@ -625,8 +625,6 @@ function cardHtml(it,cls){
/* 资料页可能同时收录番号和非番号作品;版式按钮属于页面,但封套比例只施加给
真实 `is_jav` 卡片,不能把同页的创作者视频也拉成竖封。 */
const jav=javActive()&&!!it.is_jav,layout=javLayout();
- // 小图是页面版式,不是单条资产属性。同一页混入非番号作品时也必须同高。
- const smallLayout=javActive()&&layout==='small';
const parts=it.part_group||null;
const useCover=jav&&layout!=='preview'&&it.has_cover;
/* 卡片比例。这个值以前算出来就没人用过——`.pic` 一直写死 16/9,于是 JAV 的两种
@@ -674,7 +672,7 @@ function cardHtml(it,cls){
// 会在普通卡片里折成三行;「第一位 + 等 N 人」仍能说明身份与规模。
const coStarred=performers.length>1&&!primaryCreator;
const avatar=coStarred
- ? `<div class="mavstack">${performers.slice(0,smallLayout?2:3)
+ ? `<div class="mavstack">${performers.slice(0,3)
.map((nm,i)=>`<button class="mav entitylink" data-entity-kind="performer" data-entity-name="${esc(nm)}" title="打开${esc(performerLabel(it))}页:${esc(nm)}">${avatarInner(nm,performerRefs[i],REP[nm])}</button>`)
.join('')}</div>`
: (()=>{
@@ -700,7 +698,8 @@ function cardHtml(it,cls){
<button data-seek="-${appSettings.seekSeconds}" title="后退 ${appSettings.seekSeconds} 秒" aria-label="后退 ${appSettings.seekSeconds} 秒">${icon('rotate-ccw')}<b>${appSettings.seekSeconds}</b></button>
<button data-seek="${appSettings.seekSeconds}" title="前进 ${appSettings.seekSeconds} 秒" aria-label="前进 ${appSettings.seekSeconds} 秒">${icon('rotate-cw')}<b>${appSettings.seekSeconds}</b></button>
<button data-open title="打开详情" aria-label="打开详情">${icon('maximize')}</button></div>`;
- return `<article class="card ${parts?'partcard ':''}${smallLayout?'jav-small ':''}${cls||''} ${it.disposal==='trash'?'pending-delete':''}" data-id="${it.id}"${parts?` data-part-seed="${parts.seed_id}"`:''}>
+ /* 小图与预览图都是 16:9 横图,只更换图片来源;元数据 DOM 和高度必须完全相同。 */
+ return `<article class="card ${parts?'partcard ':''}${cls||''} ${it.disposal==='trash'?'pending-delete':''}" data-id="${it.id}"${parts?` data-part-seed="${parts.seed_id}"`:''}>
${parts?'<div class="partstack">':''}<div class="pic" style="--card-ratio:${ar}">${thumb}<button class="cardopenhit" data-open aria-label="打开 ${esc(shownName)}${parts?'分卷':'详情'}"></button>
<div class="badge mono">${srcBadge(it.location,it.cost)}</div>
<span class="selectionMark">${icon('check')}</span><span class="deleteMark">${icon('trash')}<b>回收站</b></span>