Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(follow): 关注页筛选行不配全选与全不选键

longmeidaoceb9f2cd85e3
diff --git a/tests/test_follow_web.py b/tests/test_follow_web.py
index cbe95189c..19cf3cc2c 100644
--- a/tests/test_follow_web.py
+++ b/tests/test_follow_web.py
@@ -1868,8 +1868,8 @@ class FollowWebSourceTests(unittest.TestCase):
bulk = self.page[self.page.index(".fsrcbulk{"):]
self.assertIn("border-bottom:1px solid var(--border-10)", bulk[:bulk.index("}")])
- def test_follow_filter_rows_are_multi_select_with_select_all_and_select_none(self):
- """关注页的作者、来源两行多选,各带「全选/全不选」;标签行是交集,只给「全不选」。
+ def test_follow_filter_rows_are_multi_select_without_bulk_keys(self):
+ """关注页的作者、来源、标签三行都是多选,行首不配「全选/全不选」:这一页是浏览用的。
选中状态只有三个 Set 一份真相,URL 里按逗号拼;服务端同样按逗号拆。
"""
@@ -1879,20 +1879,14 @@ class FollowWebSourceTests(unittest.TestCase):
self.assertNotIn("followProvider=", self.page.replace("followProviders=", ""))
render = self.page[self.page.index("function renderFollow("):
self.page.index("function followAuthorGroups(")]
- self.assertIn("followBulkButtons('authors',followAuthors.size,authors.size)", render)
- self.assertIn("followBulkButtons('providers',followProviders.size,providers.size)", render)
- self.assertIn("followBulkButtons('tags',followTags.size,topTags.length,{all:false})", render)
self.assertIn('aria-pressed="${followAuthors.has(key)}"', render)
self.assertIn('aria-pressed="${followProviders.has(key)}"', render)
- self.assertIn("followAuthors=new Set(all?authors.keys():[])", render)
- self.assertIn("followProviders=new Set(all?providers.keys():[])", render)
- helper = self.page[self.page.index("function followBulkButtons("):
- self.page.index("function followMediaControl(")]
- self.assertIn('data-bulk-all${selected>=total?\' disabled\':\'\'}>全选</button>', helper)
- self.assertIn('data-bulk-none${selected?\'\':\' disabled\'}>全不选</button>', helper)
+ self.assertIn('aria-pressed="${followTags.has(key)}"', render)
+ self.assertNotIn("followBulkButtons", self.page)
+ self.assertNotIn("data-bulk-all", self.page)
+ self.assertNotIn(".followauthors .fbulk{", self.page)
self.assertIn("params.set('author',[...followAuthors].join(','))", self.page)
self.assertIn("params.set('provider',[...followProviders].join(','))", self.page)
- self.assertIn(".followauthors .fbulk{flex-direction:column", self.page)
def test_the_manage_page_is_ordered_by_what_you_do_first(self):
# 只看管理页那一段:同样的标题在别的页面上也出现过,全页搜索会命中错的那个。
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 27942be5c..1df6e0dd4 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -7473,7 +7473,7 @@ class WebUiSourceTests(unittest.TestCase):
self.assertIn("if (!groupCards.length) continue;", bulk)
def test_the_follow_batch_bar_only_carries_row_actions(self):
- """关注页的批量条只有保存、跳过这类按行动作;勾选靠每行行首的全选/全不选。"""
+ """关注页的批量条只有保存、跳过这类按行动作:这一页是浏览用的,不配全选键。"""
self.assertPageLacks('id="followBatchAll"')
self.assertPageLacks("#followBatchAll")
self.assertPageContains("$('#batchbar').querySelectorAll('[data-follow-batch]').forEach(button=>button.hidden=!followPage);")
diff --git a/web/app.js b/web/app.js
index 0beeefb95..937d06ea6 100644
--- a/web/app.js
+++ b/web/app.js
@@ -5186,15 +5186,8 @@ function readFollowView(){
followFilter=(status===null||status==='all')?'':status;
followMediaView=params.get('media')==='images'?'images':'videos';
}
-/* 作者、来源两行是多选:按下的算「只看这些」,一个都不按就是全部。「全选」把这一行
- 全部按下,之后再抬起几个就是排除法;「全不选」抬起全部,回到不筛。标签行是
- 「同时具备」的交集(服务端如此判),全部按下只会一条不中,所以那一行只给「全不选」。
- 两个按钮在无事可做时禁用:全按下了就没有「全选」,一个没按就没有「全不选」。 */
-function followBulkButtons(dim,selected,total,{all=true}={}){
- return `<span class="fbulk" role="group" aria-label="批量选择">${all
- ?`<button type="button" class="geist-button" data-follow-bulk="${dim}" data-bulk-all${selected>=total?' disabled':''}>全选</button>`:''
- }<button type="button" class="geist-button" data-follow-bulk="${dim}" data-bulk-none${selected?'':' disabled'}>全不选</button></span>`;
-}
+/* 作者、来源两行是多选:按下的算「只看这些」,一个都不按就是全部;标签行是「同时具备」的
+ 交集(服务端如此判)。这一页是浏览用的,不配批量选择键,想回到不筛就把按下的几个抬起来。 */
function followMediaControl(counts){
if(!counts.images&&followMediaView!=='images')return '';
return mediaViewButtonsHtml({active:followMediaView,videoCount:counts.videos,imageCount:counts.images});
@@ -5254,18 +5247,15 @@ function renderFollow(){
$('#stats').innerHTML=`<div class="follow">
<div class="followhead"><h2 class="disp pagetitle">关注</h2>
<button class="fbtn primary fcheck" data-follow-manage>${icon('settings')}管理关注</button></div>
- ${authors.size?`<div class="tier followauthors" aria-label="按作者筛选">${
- followBulkButtons('authors',followAuthors.size,authors.size)}${randomizedAuthors.map(([key,author])=>
+ ${authors.size?`<div class="tier followauthors" aria-label="按作者筛选">${randomizedAuthors.map(([key,author])=>
`<button class="av" data-follow-author="${esc(key)}" aria-pressed="${followAuthors.has(key)}">
<span class="ring">${followAuthorAvatar(author.sources)}</span><span class="nm">${esc(author.name)}</span></button>`
).join('')}</div>`:''}
<div class="tagbar followfilters" aria-label="关注筛选">${followMediaControl(mediaCounts)}${FOLLOW_FILTERS.map(([key,label])=>
`<button class="pill" data-follow-filter="${key}" aria-pressed="${key===followFilter}">${label}${
` <span class="n mono">${key?counts[key]||0:allCount}</span>`}</button>`).join('')}
- ${providerPills?`<span class="sep" aria-hidden="true"></span>${
- followBulkButtons('providers',followProviders.size,providers.size)}${providerPills}`:''}
- ${topTags.length?`<span class="sep" aria-hidden="true"></span>${
- followBulkButtons('tags',followTags.size,topTags.length,{all:false})}`+
+ ${providerPills?`<span class="sep" aria-hidden="true"></span>${providerPills}`:''}
+ ${topTags.length?`<span class="sep" aria-hidden="true"></span>`+
topTags.map(([key,label,n])=>
`<button class="pill r34-${esc(groupTagType(groups,key))}" data-follow-tag="${esc(key)}" aria-pressed="${followTags.has(key)}">${
esc(label)}${n?` <span class="n mono">${n}</span>`:''}</button>`).join(''):''}</div>
@@ -5307,12 +5297,6 @@ function renderFollow(){
toggle(followProviders,button.dataset.followProvider);applyFollowView()});
$('#stats').querySelectorAll('[data-follow-tag]').forEach(button=>button.onclick=()=>{
toggle(followTags,button.dataset.followTag);applyFollowView()});
- $('#stats').querySelectorAll('[data-follow-bulk]').forEach(button=>button.onclick=()=>{
- const all=button.hasAttribute('data-bulk-all');
- if(button.dataset.followBulk==='authors')followAuthors=new Set(all?authors.keys():[]);
- else if(button.dataset.followBulk==='providers')followProviders=new Set(all?providers.keys():[]);
- else followTags=new Set();
- applyFollowView()});
$('#stats').querySelectorAll('[data-follow-manage]').forEach(button=>
button.onclick=()=>openFollowManage());
diff --git a/web/css/21-online.css b/web/css/21-online.css
index 7b7380b93..df8849156 100644
--- a/web/css/21-online.css
+++ b/web/css/21-online.css
@@ -9,10 +9,6 @@
.followauthors .av[aria-pressed="true"] .ring{box-shadow:0 0 0 2px var(--ink)}
.followauthors .favatar{width:64px;height:64px;border-radius:50%;outline:0}
.followauthors .favatar.none{font-size:var(--fs-lg);background:var(--overlay-5)}
-/* 每行开头的「全选/全不选」:作者行按头像高度竖排两颗,筛选条上横排。 */
-.fbulk{display:inline-flex;flex:none;align-items:center;gap:4px;margin-right:6px}
-.fbulk .geist-button{height:28px;padding:0 10px;font-size:var(--fs-sm);white-space:nowrap}
-.followauthors .fbulk{flex-direction:column;align-self:center;margin-right:10px}
.followfilters{position:relative;top:auto;z-index:1;height:auto;min-height:58px;margin:0 0 16px;
padding:9px 0 8px;border-bottom-color:transparent;scrollbar-width:none;overscroll-behavior-inline:contain;
touch-action:pan-x}