Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 索引页表头窄屏把开关另起一行,字母表条目单行截断并换成 Aa 图标

longmeidaodbd38698831c
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 644389519..91e252040 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -5064,6 +5064,45 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("indexheading")
self.assertPageContains("${icon('database')}本地")
+ def test_an_alphabet_entry_stays_on_one_line(self):
+ """一枚标签占一行,长名字截断。
+
+ `text-overflow:ellipsis` 少了 `white-space:nowrap` 就永远不触发:实测在线
+ 词表里 clothed_female_nude_male 一类名字改成折行,同一行其它标签被拉高,
+ 两列的行高也对不齐。
+ """
+ self.assertPageContains(
+ ".alphatag span:first-of-type{overflow:hidden;text-overflow:ellipsis;"
+ "white-space:nowrap;flex:1}")
+
+ def test_the_index_header_moves_the_switches_to_their_own_row_when_narrow(self):
+ """表头一行放不下五样东西,挤在一行时每样都被压成竖排两行。
+
+ 实测 459px 视口:标题「标签」两字上下叠、计数叠成两行、四个开关按钮各自
+ 叠成两行、过滤框被压成 0 宽。760px 以下改成标题与过滤框一行、开关另起一行。
+ """
+ self.assertPageContains("@media (max-width:760px){\n .index .ihead{flex-wrap:wrap}")
+ self.assertPageContains(" .indexheading,#indexCount,.tagmodes button{white-space:nowrap}")
+ # 换行位靠一个零高的伪元素占满整行,开关的 order 排在它之后。
+ self.assertPageContains(' .index .ihead::after{content:"";order:2;flex-basis:100%;height:0}')
+ self.assertPageContains(" .index .ihead .geist-search{order:1}")
+ self.assertPageContains(
+ " .index .ihead .tagmodes,.index .ihead .iconswitch{order:3;flex:none}")
+
+ def test_the_alphabet_switch_is_labelled_with_the_aa_glyph(self):
+ """字母表按钮的图标要说「按字母排」,不是三条粗细不同的横线。
+
+ `list-filter` 是筛选,和它旁边的「标签云」讲的不是同一件事;Aa 取 vendored
+ lucide-static 1.37.0 的 a-large-small,不另画。
+ """
+ self.assertPageContains("${icon('a-large-small')}字母表")
+ self.assertPageContains(
+ '<symbol id="i-a-large-small" viewBox="0 0 24 24">'
+ '<path d="m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16" />'
+ '<path d="M15.697 14h5.606" />'
+ '<path d="m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16" />'
+ '<path d="M3.304 13h6.392" /></symbol>')
+
def test_an_online_tag_opens_the_follow_page_not_a_catalog_filter(self):
"""在线标签标注的是还没入库的在线更新,拿去筛目录必然一条不中。"""
self.assertPageContains("if(onlineTags){")
diff --git a/web/app.js b/web/app.js
index 46bcf8b60..ff466e521 100644
--- a/web/app.js
+++ b/web/app.js
@@ -5239,7 +5239,7 @@ async function openIndex(kind,q,push=true,refine=false){
<h2 class="disp indexheading">${kind==='tags'?icon('tags'):''}${title}</h2>
<span class="mono" id="indexCount">${countText}</span>
${kind==='tags'?`<div class="tagmodes"><button data-tag-scope="local" aria-pressed="${!onlineTags}">${icon('database')}本地</button><button data-tag-scope="online" aria-pressed="${onlineTags}">${icon('globe')}在线</button></div>
- <div class="tagmodes"><button data-tag-view="cloud" aria-pressed="${tagIndexMode==='cloud'}">${icon('tags')}标签云</button><button data-tag-view="alphabet" aria-pressed="${tagIndexMode==='alphabet'}">${icon('list-filter')}字母表</button></div>`:''}
+ <div class="tagmodes"><button data-tag-view="cloud" aria-pressed="${tagIndexMode==='cloud'}">${icon('tags')}标签云</button><button data-tag-view="alphabet" aria-pressed="${tagIndexMode==='alphabet'}">${icon('a-large-small')}字母表</button></div>`:''}
${people?peopleLayoutButtons():''}
${searchInputHtml({id:'iq',label:'过滤'+title,value:q||''})}
</div><div id="indexFilters">${filters}</div><div id="indexBody">${body}</div><button class="indexmore" id="indexMore" type="button" ${d.has_more?'':'hidden'}>载入更多</button>`;
diff --git a/web/css/06-index.css b/web/css/06-index.css
index f7d29374d..116943216 100644
--- a/web/css/06-index.css
+++ b/web/css/06-index.css
@@ -81,5 +81,17 @@ body.entity-open .index{overflow-x:visible}
.alphalist{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:5px 18px}
.alphatag{display:flex;align-items:center;justify-content:flex-start;gap:9px;border:0;background:transparent;
color:var(--ink-2);padding:7px 8px;border-radius:var(--control-radius);text-align:left;cursor:pointer;min-width:0}
-.alphatag:hover{background:color-mix(in srgb,var(--tag-color) 9%,transparent);color:var(--ink)}.alphatag span:first-of-type{overflow:hidden;text-overflow:ellipsis;flex:1}
+.alphatag:hover{background:color-mix(in srgb,var(--tag-color) 9%,transparent);color:var(--ink)}/* nowrap 是省略号的前提:少了它 text-overflow 永远不触发,长标签改成折行,
+ 同一行里的其它标签跟着被拉高,两列各行高度还对不齐。 */
+.alphatag span:first-of-type{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}
.alphatag .n{color:var(--muted);font-size:var(--fs-xs);flex:none}
+/* 表头一行放不下五样东西:标题、计数、两组开关、过滤框。挤在一行时每样都被压到
+ 竖排两行,过滤框直接被压成 0 宽。窄屏改成标题与过滤框一行、开关另起一行;
+ 开关自己 flex:none,宁可整组换行也不把「标签云」拆成两行。 */
+@media (max-width:760px){
+ .index .ihead{flex-wrap:wrap}
+ .indexheading,#indexCount,.tagmodes button{white-space:nowrap}
+ .index .ihead .geist-search{order:1}
+ .index .ihead::after{content:"";order:2;flex-basis:100%;height:0}
+ .index .ihead .tagmodes,.index .ihead .iconswitch{order:3;flex:none}
+}
diff --git a/web/index.html b/web/index.html
index 1468ccb55..f944ba11a 100644
--- a/web/index.html
+++ b/web/index.html
@@ -27,6 +27,7 @@
<symbol id="i-tags" viewBox="0 0 24 24"><path d="M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z" /><path d="M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193" /><circle cx="10.5" cy="6.5" r=".5" fill="currentColor" /></symbol>
<symbol id="i-star" viewBox="0 0 24 24"><path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z" /></symbol>
<symbol id="i-list-filter" viewBox="0 0 24 24"><path d="M2 5h20" /><path d="M6 12h12" /><path d="M9 19h6" /></symbol>
+ <symbol id="i-a-large-small" viewBox="0 0 24 24"><path d="m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16" /><path d="M15.697 14h5.606" /><path d="m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16" /><path d="M3.304 13h6.392" /></symbol>
<symbol id="i-sort" viewBox="0 0 24 24"><path d="m3 16 4 4 4-4" /><path d="M7 20V4" /><path d="M11 4h10" /><path d="M11 8h7" /><path d="M11 12h4" /></symbol>
<symbol id="i-arrow-down" viewBox="0 0 24 24"><path d="M12 5v14" /><path d="m19 12-7 7-7-7" /></symbol>
<symbol id="i-arrow-up" viewBox="0 0 24 24"><path d="m5 12 7-7 7 7" /><path d="M12 19V5" /></symbol>