Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(follow): keep media buttons first

longmeidao7e6e3aa5936b
diff --git a/tests/test_follow_web.py b/tests/test_follow_web.py
index eb998d593..96194ff47 100644
--- a/tests/test_follow_web.py
+++ b/tests/test_follow_web.py
@@ -1839,25 +1839,29 @@ class FollowWebSourceTests(unittest.TestCase):
self.assertPageContains('data-follow-queue-item="${item.id}"')
self.assertPageContains("openFollowDetail(+button.dataset.followCollection)")
- def test_follow_reuses_entity_media_buttons_and_offers_the_vercel_switch_variant(self):
+ def test_follow_reuses_entity_media_buttons_at_the_far_left_without_separator(self):
self.assertPageContains("const followMediaKinds=group=>")
self.assertPageContains("function followItemMediaKinds(item)")
self.assertPageContains("const item=followItemForMedia(group)")
self.assertPageContains('class="followmediaicons"')
self.assertPageContains('class="entitymediatoggle" type="button" data-follow-media="videos"')
- self.assertPageContains('class="insightswitch followmediaswitch" role="radiogroup"')
self.assertPageContains('data-follow-media="videos"')
self.assertPageContains('data-follow-media="images"')
- self.assertPageContains("followMediaUi=FOLLOW_MEDIA_UIS.has(params.get('media-ui'))")
+ self.assertPageLacks('class="insightswitch followmediaswitch"')
+ self.assertPageLacks("params.set('media-ui','switch')")
self.assertPageContains("params.set('author',followAuthor)")
self.assertPageContains("route(followViewPath());renderFollow()")
self.assertPageContains("const preferredKind=followMediaView==='images'?'image':'video'")
watch = self.page.split("function renderFollow(){", 1)[1].split(
"function followBackfillState", 1)[0]
- self.assertLess(watch.index('class="tier followauthors"'),
- watch.index('followMediaControl(mediaCounts)'))
- self.assertLess(watch.index('class="tagbar followfilters"'),
- watch.index('followMediaControl(mediaCounts)'))
+ self.assertIn(
+ 'class="tagbar followfilters" aria-label="关注筛选">${followMediaControl(mediaCounts)}${FOLLOW_FILTERS.map',
+ watch,
+ )
+ self.assertNotIn(
+ '<span class="sep" aria-hidden="true"></span>${followMediaControl(mediaCounts)}',
+ watch,
+ )
self.assertPageContains("followMediaView==='images'?' followphotowall':''")
self.assertPageContains(".followlist.followphotowall{display:block;column-count:5")
self.assertPageContains(".followitem.imagecard .followvisual .pic>img{position:relative")
diff --git a/web/app.css b/web/app.css
index 428d3c8c8..68cfd2166 100644
--- a/web/app.css
+++ b/web/app.css
@@ -1746,10 +1746,6 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位
.followmediaicons .entitymediatoggle[data-follow-media="images"] svg{fill:currentColor;stroke:none}
.followmediaicons .entitymediatoggle:hover{background:var(--overlay-5);color:var(--ink)}
.followmediaicons .entitymediatoggle[aria-pressed="true"]{background:var(--ink-2);color:var(--ground)}
-.followmediaswitch{flex:none;padding:2px;border-radius:7px}.followmediaswitch span{height:28px;grid-auto-flow:column;gap:6px;padding:0 10px}
-.followmediaswitch svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:2}
-.followmediaswitch label:last-child svg{fill:currentColor;stroke:none}
-.followmediaswitch b{font-size:var(--fs-xs);font-weight:400;color:inherit}
/* 折叠摘要按 Vercel 设置行的 title + description 结构:标题一行、说明弱化一行,
尖角指引符与文字之间留出固定间距,不再靠一个空格硬贴。 */
.fdetails{margin-inline:-16px}
diff --git a/web/app.js b/web/app.js
index c63dcbe98..2c7082c5e 100644
--- a/web/app.js
+++ b/web/app.js
@@ -2638,20 +2638,15 @@ function followCheckFailNote(report){
}
/* ── 看的那一页 ── */
-let followAuthor='',followProvider='',followTags=new Set(),followMediaView='videos',followMediaUi='buttons',followGroupByItemId=new Map(),followItemsById=new Map(),followDetailReturnPath='/follow';
-const FOLLOW_MEDIA_UIS=new Set(['buttons','switch']);
+let followAuthor='',followProvider='',followTags=new Set(),followMediaView='videos',followGroupByItemId=new Map(),followItemsById=new Map(),followDetailReturnPath='/follow';
function followViewPath(){
const params=new URLSearchParams();
if(followAuthor)params.set('author',followAuthor);
if(followMediaView==='images')params.set('media','images');
- if(followMediaUi==='switch')params.set('media-ui','switch');
const search=params.toString();return '/follow'+(search?'?'+search:'');
}
function followMediaControl(counts){
if(!counts.images)return '';
- if(followMediaUi==='switch')return `<div class="insightswitch followmediaswitch" role="radiogroup" aria-label="关注媒体类型">
- <label><input type="radio" name="follow-media" data-follow-media="videos"${followMediaView==='videos'?' checked':''}><span>${icon('play')}视频 <b class="mono">${counts.videos.toLocaleString()}</b></span></label>
- <label><input type="radio" name="follow-media" data-follow-media="images"${followMediaView==='images'?' checked':''}><span>${icon('pics')}图片 <b class="mono">${counts.images.toLocaleString()}</b></span></label></div>`;
return `<div class="followmediaicons" role="group" aria-label="关注媒体类型">
<button class="entitymediatoggle" type="button" data-follow-media="videos" aria-pressed="${followMediaView==='videos'}"
aria-label="视频 ${counts.videos.toLocaleString()}" title="视频 ${counts.videos.toLocaleString()}">${icon('play')}</button>
@@ -2726,10 +2721,9 @@ function renderFollow(){
`<button class="av" data-follow-author="${esc(key)}" aria-pressed="${key===followAuthor}">
<span class="ring">${followAuthorAvatar(author.sources)}</span><span class="nm">${esc(author.name)}</span></button>`
).join('')}</div>`:''}
- <div class="tagbar followfilters" aria-label="关注筛选">${FOLLOW_FILTERS.map(([key,label])=>
+ <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('')}
- ${mediaCounts.images?`<span class="sep" aria-hidden="true"></span>${followMediaControl(mediaCounts)}`:''}
${providerPills?`<span class="sep" aria-hidden="true"></span>${providerPills}`:''}
${topTags.length?`<span class="sep" aria-hidden="true"></span>`+
topTags.map(([key,label,n])=>
@@ -2813,12 +2807,11 @@ function wireFollowOlder(){
async function openFollow(push=true,renderForDetail=false){
releaseHoverPreviews();disposeStage(false);
document.body.classList.remove('entity-open','index-open');
- if(push){followAuthor='';followMediaView='videos';followMediaUi='buttons';route('/follow')}
+ if(push){followAuthor='';followMediaView='videos';route('/follow')}
else if(location.pathname==='/follow'){
const params=new URLSearchParams(location.search);
followAuthor=params.get('author')||'';
followMediaView=params.get('media')==='images'?'images':'videos';
- followMediaUi=FOLLOW_MEDIA_UIS.has(params.get('media-ui'))?params.get('media-ui'):'buttons';
}
const surface=claimSurface(renderForDetail?surfacePath():'/follow');
$('#stats').hidden=false;$('#index').hidden=true;$('#grid').innerHTML='';