Peach: Local-first video metadata scraper and media manager.
fix(follow): align detail and filtering behavior
longmeidaob18e4106f9cf
diff --git a/README.md b/README.mdindex b7e3384d5..aa108155e 100644--- a/README.md+++ b/README.md@@ -104,7 +104,7 @@ macOS/Linux 用 `./scripts/test.sh follow`。可选域为 `follow`、`catalog`关注管理支持粘贴链接、名称或 ID,也可直接登记 FANBOX、Patreon 和 SubscribeStar 的官方创作者页。每个渠道的复选框决定它是否参与检查更新;联网只发生在显式查找和检查更新时,-服务启动、健康检查和普通浏览不会联网。+关闭的渠道也不会出现在关注观看页,重新启用后恢复显示。服务启动、健康检查和普通浏览不会联网。F95zone 站内索引没有命中名称时,结果区会给出对应的 Google 查询入口;Google 结果只供人核对真实线程链接,不会自动登记来源。Rule34.xxx 标签身份不区分大小写。跨站来源按规范作者归组,F95 标题中的 `Collection(s)` 不属于作者名。diff --git a/src/peach/web_follow.py b/src/peach/web_follow.pyindex 95e9268f7..4f5d6fd90 100644--- a/src/peach/web_follow.py+++ b/src/peach/web_follow.py@@ -480,17 +480,21 @@ def q_follow(contract, args) -> dict:alias_map, author_aliases = _follow_alias_state(connection)sources = [_source_payload(row, alias_map) for row in source_rows]alias_suggestions = _follow_alias_suggestions(source_rows, alias_map)+ enabled_source_ids = {int(row["id"]) for row in source_rows if row["enabled"]}items = tuple(item for item in store.items(statuses=statuses, source_id=source_id, limit=limit)- if not _excluded_item(item))+ if item.source_id in enabled_source_ids and not _excluded_item(item))groups = [_group_payload(group) for group in store.group(items)]counts = dict(connection.execute(- "SELECT status, count(*) FROM follow_item GROUP BY status").fetchall())+ "SELECT i.status, count(*) FROM follow_item i"+ " JOIN follow_source s ON s.id=i.source_id"+ " WHERE s.enabled=1 GROUP BY i.status").fetchall())excluded_marks = ",".join("?" for _ in RULE34VIDEO_EXCLUDED_IDS)excluded_counts = connection.execute("SELECT i.status, count(*) FROM follow_item i"" JOIN follow_source s ON s.id=i.source_id"- f" WHERE s.provider='rule34video' AND i.external_id IN ({excluded_marks})"+ f" WHERE s.enabled=1 AND s.provider='rule34video'"+ f" AND i.external_id IN ({excluded_marks})"" GROUP BY i.status",tuple(RULE34VIDEO_EXCLUDED_IDS),).fetchall()diff --git a/tests/test_follow_web.py b/tests/test_follow_web.pyindex f7bff83e4..32022c8ec 100644--- a/tests/test_follow_web.py+++ b/tests/test_follow_web.py@@ -623,6 +623,19 @@ class FollowSourceAddTests(FollowContractTests):}])self.assertEqual(self._get()["sources"], [], "查找入口不能自动登记来源")+ def test_a_fanbox_subdomain_url_is_shown_as_an_addable_candidate(self):+ result = self._post("/api/follow/resolve", {+ "lines": ["https://lazyprocrast.fanbox.cc/"]})++ row = result["results"][0]+ self.assertEqual(row["kind"], "url")+ self.assertEqual(row["candidates"], [{+ "provider": "fanbox", "provider_label": "FANBOX",+ "ref": "lazyprocrast", "url": "https://lazyprocrast.fanbox.cc/",+ "label": "lazyprocrast", "author": "", "semantics": "work",+ "evidence": "链接直接指明", "known": False,+ }])+def test_a_thread_link_is_registered_with_release_semantics(self):self._add("https://f95zone.to/threads/""lazy-procrastinator-collection-2026-06-28-lazyprocrast.50685/")@@ -700,7 +713,10 @@ class FollowSourceAddTests(FollowContractTests):result = self._post("/api/follow/source", {"action": "enabled", "id": source_id, "enabled": False})self.assertFalse(result["enabled"])- self.assertFalse(self._get()["sources"][0]["enabled"])+ payload = self._get()+ self.assertFalse(payload["sources"][0]["enabled"])+ self.assertEqual(payload["groups"], [], "暂停的来源不应继续出现在关注流")+ self.assertEqual(payload["counts"]["new"], 0)with mock.patch.object(web_follow, "build_connector") as factory:checked = self._post("/api/follow/check", {})self.assertEqual(checked["checked"], 0)@@ -893,6 +909,7 @@ class FollowWebSourceTests(unittest.TestCase):self.assertPageContains('<div class="fpicks"><div class="fsechead"><h3>查找结果</h3>')self.assertPageContains('<p class="fpickempty">站内没有查到来源</p>')+ self.assertPageContains("box.scrollIntoView({block:'nearest',behavior:'smooth'})")self.assertNotIn(".fpicks h3{", page,"查找结果不应另起一套标题字号")@@ -940,6 +957,7 @@ class FollowWebSourceTests(unittest.TestCase):icons = self.page.split("const SOURCE_ICONS={", 1)[1].split("};", 1)[0]for provider in ("fanbox", "patreon", "subscribestar"):self.assertIn(provider, icons)+ self.assertIn("assets.subscribestar.com/assets/public/images/favicons/favicon-32x32-", icons)self.assertPageContains("followAliasManager(followData.author_aliases,followData.alias_suggestions)")self.assertPageContains("'/api/follow/author-alias'")@@ -1132,8 +1150,9 @@ class FollowWebSourceTests(unittest.TestCase):self.assertPageContains('class="tagbar followfilters"')self.assertPageContains('class="pill sourcepill" data-follow-provider=')self.assertPageContains("内容标签目前由 ${")- self.assertPageContains(".sort((a,b)=>b[1]-a[1]).slice(0,20)")- self.assertPageContains(".map(([tag,n])=>[tag,tagLabel(tag),n])")+ self.assertPageContains("const rankedTags=[...tagCounts].sort((a,b)=>b[1]-a[1])")+ self.assertPageContains("const topTagRows=rankedTags.slice(0,20)")+ self.assertPageContains("topTagRows.push([tag,tagCounts.get(tag)])")def test_follow_tags_are_multi_select_and_use_rule34_property_colours(self):self.assertPageContains("let followAuthor='',followProvider='',followTags=new Set()")@@ -1143,6 +1162,7 @@ class FollowWebSourceTests(unittest.TestCase):self.assertPageContains(".r34-character")self.assertPageContains(".r34-copyright")self.assertPageContains(".r34-metadata")+ self.assertPageContains('[class*="r34-"][aria-pressed="true"]')def test_follow_cards_use_author_avatars_and_open_details_inside_peach(self):self.assertPageContains("return followCard(group,siblings)")@@ -1155,13 +1175,19 @@ class FollowWebSourceTests(unittest.TestCase):self.assertPageContains("const src=item.playable?`/follow-stream?id=${item.id}`:''")self.assertPageContains('data-follow-detail="${item.id}"')self.assertPageContains("route(`/follow/item/${item.id}`)")- self.assertPageContains('class="sgrid followdetailgrid"')+ self.assertPageContains('class="sgrid followdetailgrid${collection?\' mixgrid\':\'\'}"')self.assertPageContains('class="followorigin" href="${esc(item.url)}" target="_blank"')+ self.assertPageContains('title="打开来源页面" aria-label="打开来源页面"')+ self.assertNotIn('打开来源页面</a>', self.page)+ self.assertPageContains("followAuthorAvatar(authorSources)")+ self.assertPageContains("followTagChip(item,tag,'button')")+ self.assertPageContains(".followdetailtags .tg{max-width:none")+ self.assertPageContains("const postedBy=item.author&&foldName(item.author)!==foldName(author)")self.assertPageContains("openFollowDetail(id);")self.assertNotIn('class="cardopenhit" href=', self.page)self.assertNotIn('class="t cardtitle" href=', self.page)self.assertNotIn('class="fcollectionthumb" href=', self.page)- self.assertPageContains("const closeDetail=()=>{disposeStage(true);openFollow(false)}")+ self.assertPageContains("route(followDetailReturnPath||'/follow')")self.assertPageContains(".followitem a{text-decoration:none}")def test_follow_filters_put_all_first_and_sources_are_icon_only(self):@@ -1372,11 +1398,12 @@ class FollowWebSourceTests(unittest.TestCase):self.assertPageContains("const name=followAuthorName(group);")self.assertPageContains("const official=group.find(source=>source.official_avatar_url);")self.assertPageContains("if(officialName)return officialName;")- # 取不到头像时是一个明确的空位,不是首字母——首字母会让「未取得」看着像取到了。- self.assertPageContains("这些来源没有可取的头像")+ # 取不到图片时回退作者首字母;不能从来源标签切出中文“初”“一”。+ self.assertPageContains("function followAvatarInitial(group)")+ self.assertPageContains('title="没有可用头像"')avatar = self.page[self.page.index("function followAuthorAvatar(group)"):]avatar = avatar[:avatar.index("function followAuthorBlock")]- self.assertNotIn("charAt", avatar, "不许用首字母冒充头像")+ self.assertIn("followAvatarInitial(group)", avatar)self.assertIn("source.avatar_url", avatar)self.assertIn("source.official_avatar_url", avatar)self.assertIn("data-fallback", avatar)@@ -1389,7 +1416,7 @@ class FollowWebSourceTests(unittest.TestCase):self.assertPageContains("媒体需要登录会话才能取,发现本身不需要")def test_follow_styles_exist_for_the_card_surface(self):- for selector in (".followlist{", ".followitem{", ".fbadge{", ".fcollectionlist{"):+ for selector in (".followlist{", ".followitem{", ".fbadge{", ".followqueue"):self.assertPageContains(selector)def test_follow_cards_reuse_home_cards_hover_actions_and_mix_stacks(self):@@ -1398,7 +1425,9 @@ class FollowWebSourceTests(unittest.TestCase):self.assertPageContains('class="mixbadge" data-follow-collection=')self.assertPageContains(".factions{position:absolute;right:10px;top:10px")self.assertPageContains("@media (hover:hover) and (pointer:fine){.followitem:hover .factions")- self.assertPageContains("function openFollowCollection(group)")+ self.assertPageContains("function followQueueHtml(group,itemId)")+ self.assertPageContains('data-follow-queue-item="${item.id}"')+ self.assertPageContains("openFollowDetail(+button.dataset.followCollection)")def test_follow_uses_the_global_multi_select_mode(self):self.assertPageContains("const selected=new Set(),followSelected=new Set();")@@ -1407,6 +1436,12 @@ class FollowWebSourceTests(unittest.TestCase):self.assertPageContains('data-follow-batch="save"')self.assertPageContains("const body=action==='save'?{items}:{items,to:action};")+ def test_ignore_actions_do_not_reuse_the_close_icon(self):+ self.assertPageContains('<symbol id="i-eye-off"')+ self.assertPageContains('data-follow-batch="ignored" hidden><svg viewBox="0 0 24 24"><use href="#i-eye-off"')+ self.assertPageContains('data-follow-detail-status="ignored" aria-label="忽略" title="忽略"')+ self.assertPageContains("${icon('eye-off')}</button>")+def test_the_check_button_stays_visible_on_a_narrow_viewport(self):# 管理入口不再混进横滚筛选条;390 宽下始终留在标题右侧。self.assertPageContains(".followhead{display:flex;align-items:center;justify-content:space-between")diff --git a/web/app.css b/web/app.cssindex 85b2d11fe..27b7ebab9 100644--- a/web/app.css+++ b/web/app.css@@ -1219,7 +1219,9 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位.fsourceavatar:hover{box-shadow:none}.fsourceavatar .favatar{position:absolute;inset:0;width:100%;height:100%;border-radius:50%;outline:0;object-fit:cover}.fsourceavatar .favatar.none{display:grid;place-items:center;font-size:var(--fs-sm);color:var(--muted)}.followitem .cardtitle{display:block;width:100%;border:0;background:transparent;color:inherit;padding:0;text-align:left;font-family:inherit;cursor:pointer;text-decoration:none}-.followitem .tg,.followdetailtags .tg,.followfilters .pill[class*="r34-"]{--r34-tag:#55A7FF;border-color:color-mix(in srgb,var(--r34-tag) 42%,transparent);background:color-mix(in srgb,var(--r34-tag) 10%,transparent)}+.followitem .tg,.followdetailtags .tg{--r34-tag:#55A7FF;border-color:color-mix(in srgb,var(--r34-tag) 42%,transparent);background:color-mix(in srgb,var(--r34-tag) 10%,transparent)}+.followfilters .pill[class*="r34-"]{--r34-tag:#55A7FF}+.followfilters .pill[class*="r34-"][aria-pressed="true"]{border-color:color-mix(in srgb,var(--r34-tag) 72%,transparent);background:color-mix(in srgb,var(--r34-tag) 22%,transparent);color:var(--ink)}.followitem .r34-artist,.followdetailtags .r34-artist,.followfilters .r34-artist{--r34-tag:#E36C6C}.followitem .r34-character,.followdetailtags .r34-character,.followfilters .r34-character{--r34-tag:#68C76F}.followitem .r34-copyright,.followdetailtags .r34-copyright,.followfilters .r34-copyright{--r34-tag:#D675D6}@@ -1243,26 +1245,17 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位@media (hover:none),(pointer:coarse){.followitem .factions{opacity:1;pointer-events:auto}}.select-mode .followitem a,.select-mode .followitem [data-follow-detail],.select-mode .followitem .factions,.select-mode .followitem .mixbadge{pointer-events:none!important}.fstate{flex:1 1 100%;font-size:var(--fs-xs);color:var(--drop)}-.followcollectiondialog{width:min(760px,calc(100vw - 28px))}.fcollectionlist{display:grid;gap:6px;max-height:62vh;overflow-y:auto;scrollbar-width:none}-.fcollectionlist::-webkit-scrollbar{display:none}-.fcollectionrow{display:grid;grid-template-columns:112px minmax(0,1fr) auto;gap:10px;align-items:center;padding:7px;border-radius:8px}-.fcollectionrow:hover{background:var(--hover)}.fcollectionthumb{position:relative;aspect-ratio:16/9;border-radius:5px;overflow:hidden;background:#000;display:grid;place-items:center}-.fcollectionthumb img{position:absolute;inset:0;width:100%;height:100%;object-fit:contain}.fcollectioncopy{min-width:0;color:inherit;text-decoration:none}-.fcollectionthumb:is(button),.fcollectioncopy:is(button){width:100%;border:0;padding:0;color:inherit;font:inherit;text-align:left;cursor:pointer}-.fcollectioncopy b,.fcollectioncopy span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.fcollectioncopy b{font-size:var(--fs-sm)}-.fcollectioncopy span{margin-top:4px;color:var(--muted);font-size:var(--fs-xs)}.fcollectioncopy .ficon{margin-right:6px}.fvkind{display:inline-block;max-width:120px;margin-right:6px;padding:1px 7px;border-radius:var(--badge-radius);overflow:hidden;text-overflow:ellipsis;vertical-align:-2px;background:var(--overlay-5);color:var(--muted);font-size:var(--fs-xs);font-style:normal}.fvkind.wip{color:var(--meter)}.fvkind.alt{color:var(--tungsten)}-.fcollectionrow>button{border:1px solid var(--border-15);border-radius:7px;background:transparent;color:var(--ink-2);padding:6px 10px;cursor:pointer}-.fcollectionrow>button:disabled{opacity:.5;cursor:default}.followdetailmedia{min-height:min(62vh,640px)}.followdetailposter{position:relative;z-index:1;display:block;width:100%;height:100%;max-height:76vh;object-fit:contain;background:#000}.followdetailplaceholder{display:grid;place-items:center;gap:10px;color:var(--muted)}.followdetailplaceholder .ficon{width:34px;height:34px;margin:0}+.followdetailtitle{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:9px;align-items:start;margin-bottom:8px}.followdetailtitle .stitle{margin:0}.followdetailtitle .followorigin{width:30px;height:30px;margin:0;display:grid;place-items:center;border-radius:7px}.followdetailtitle .followorigin:hover{background:var(--hover)}.followdetailidentity{display:flex;align-items:center;gap:10px;margin:2px 0 12px}.followdetailidentity .mav{flex:none}.followdetailidentity b,.followdetailidentity span{display:block}.followdetailidentity>div>span{margin-top:3px;color:var(--muted);font-size:var(--fs-xs)}-.followdetailsummary{margin:0 0 16px;line-height:1.6;color:var(--ink-2);white-space:pre-line}.followdetailtags .tg{color:var(--ink-2)}+.followdetailsummary{margin:0 0 16px;line-height:1.6;color:var(--ink-2);white-space:pre-line}.followdetailtags .tg{max-width:none;overflow:visible;text-overflow:clip;white-space:normal;text-align:left;color:var(--ink-2);font-family:inherit}.followqueue .mixitempic>.fnothumb{position:static;width:100%;height:100%}.followdetailactions button:disabled{opacity:.45;cursor:default}.followorigin{display:inline-flex;align-items:center;gap:7px;width:max-content;margin-top:auto;color:var(--muted);text-decoration:none}.followorigin svg{width:16px;height:16px;stroke:currentColor;fill:none}.followorigin:hover{color:var(--ink);text-decoration:none}@media (max-width:640px){.followhead{align-items:center}.follow .fcheck{height:36px;padding:0 13px}.followauthors{margin-right:-12px;padding-top:3px}.followfilters{margin-right:-12px;padding-right:12px}- .fcollectionrow{grid-template-columns:88px minmax(0,1fr)}.fcollectionrow>button{grid-column:2;justify-self:start}}+}/* ── 关注管理页 ──取证记录见 docs/reference-snapshots/vercel-geist-controls-measured.md。diff --git a/web/app.js b/web/app.jsindex d3ae5cf65..b1b9cdd4e 100644--- a/web/app.js+++ b/web/app.js@@ -1337,31 +1337,25 @@ function followCollectionCopy(group,item,mark=''){return {label,title:group.is_release&&item.author?`${item.author}:${body}`:body};}-function openFollowCollection(group){- const items=followCollectionItems(group),title=group.primary.title||'视频集合';- const dialog=playlistDialog({title,body:`<div class="fcollectionlist">${items.map(item=>{- const copy=followCollectionCopy(group,item,group.duplicates.includes(item)?item.provider_label:'');- const thumb=item.thumb_url- ?`<img src="${esc(item.thumb_url)}" alt="" loading="lazy" referrerpolicy="no-referrer" onerror="this.remove()">`- :`<span>${sourceIcon(item.provider)}</span>`;- const openAttrs=`data-follow-detail="${item.id}"`;- return `<div class="fcollectionrow"><button class="fcollectionthumb" ${openAttrs}>${thumb}</button>- <button class="fcollectioncopy" ${openAttrs}><b>${esc(copy.title)}</b>- <span class="mono"><i class="fvkind ${esc(item.variant_kind||'')}">${esc(copy.label)}</i>${sourceIcon(item.provider)}${followWhen(item)}${item.duration?` · ${fmtDur(item.duration)}`:''}</span></button>- <button data-follow-save="${item.id}"${item.status==='saved'?' disabled':''}>${item.status==='saved'?'已保存':'保存'}</button></div>`}).join('')}</div>`});- dialog.classList.add('followcollectiondialog');- dialog.querySelectorAll('[data-follow-save]').forEach(button=>button.onclick=async()=>{- button.disabled=true;- try{await api('/api/follow/save',{method:'POST',body:JSON.stringify({item:+button.dataset.followSave})});button.textContent='已保存'}- catch(error){button.disabled=false;alert(error.message||'保存失败')}- });- wireFollowDetail(dialog);+function followQueueHtml(group,itemId){+ const items=followCollectionItems(group);+ return `<aside class="mixqueue followqueue"><div class="mixqueuehead"><div><h2>${esc(group.primary.title||'视频集合')}</h2><span>${items.length} 个${items.some(item=>item.has_media)?'视频':'条目'}</span></div><div class="mixqueueactions">+ <button data-follow-queue-close title="关闭" aria-label="关闭">${icon('x')}</button></div></div><div class="mixlist">${items.map(item=>{+ const copy=followCollectionCopy(group,item,group.duplicates.includes(item)?item.provider_label:'');+ const thumb=item.thumb_url+ ?`<img src="${esc(item.thumb_url)}" alt="" loading="lazy" referrerpolicy="no-referrer" onerror="this.remove()">`+ :`<span class="fnothumb">${sourceIcon(item.provider)}</span>`;+ return `<div class="mixrow"><button class="mixitem ${item.id===itemId?'current':''}" data-follow-queue-item="${item.id}" aria-current="${item.id===itemId?'true':'false'}">+ <span class="mixitempic">${thumb}${item.duration?`<i class="dur mono">${fmtDur(item.duration)}</i>`:''}</span>+ <span class="mixitemtext"><b>${esc(copy.title)}</b><span><i class="fvkind ${esc(item.variant_kind||'')}">${esc(copy.label)}</i>${followWhen(item)}</span></span></button></div>`;+ }).join('')}</div></aside>`;}function indexFollowItems(data){const groups=data?.groups||[];- followGroupsById=new Map(groups.map(group=>[group.primary.id,group]));- followItemsById=new Map(groups.flatMap(group=>followCollectionItems(group).map(item=>[item.id,item])));+ followItemsById=new Map();followGroupByItemId=new Map();+ groups.forEach(group=>followCollectionItems(group).forEach(item=>{+ followItemsById.set(item.id,item);followGroupByItemId.set(item.id,group)}));}async function followItemById(id){@@ -1374,12 +1368,18 @@ async function followItemById(id){async function openFollowDetail(id,push=true){releaseHoverPreviews();- const returnPath=push?location.pathname+location.search:'/follow';+ const entering=!location.pathname.startsWith('/follow/item/');+ if(push&&entering)followDetailReturnPath=location.pathname+location.search;+ if(!push)followDetailReturnPath='/follow';const item=await followItemById(+id);if(!item)return;- detailReturnPath=returnPath;+ const group=followGroupByItemId.get(item.id);+ const collection=group&&followCollectionItems(group).length>1?group:null;disposeStage(false);if(push)route(`/follow/item/${item.id}`);const source=(followData?.sources||[]).find(row=>row.id===item.source_id);+ const authorSources=(followData?.sources||[]).filter(row=>+ source?.author_key&&row.author_key===source.author_key);+ if(!authorSources.length&&source)authorSources.push(source);const src=item.playable?`/follow-stream?id=${item.id}`:'';const media=item.playable&&item.media_kind==='video'?`<video controls playsinline preload="metadata" src="${src}"></video>`@@ -1389,15 +1389,17 @@ async function openFollowDetail(id,push=true){?`<img class="followdetailposter" src="${esc(item.thumb_url)}" alt="${esc(item.title)}" referrerpolicy="no-referrer">`:`<div class="followdetailplaceholder">${sourceIcon(item.provider)}<span>没有可用预览</span></div>`;const badges=followBadges({primary:item,variants:[],duplicates:[],has_wip:item.variant_kind==='wip'});- const tags=(item.tags||[]).map(tag=>followTagChip(item,tag)).join('');- const author=item.author||source?.entity_name||source?.label||item.source_label||'作者未取得';+ const tags=(item.tags||[]).map(tag=>followTagChip(item,tag,'button')).join('');+ const author=followAuthorName(authorSources)||item.author||item.source_label||'作者未取得';+ const postedBy=item.author&&foldName(item.author)!==foldName(author)?item.author:'';$('#stage').hidden=false;document.body.classList.add('detail-open');- $('#stage').innerHTML=`<div class="sgrid followdetailgrid">+ $('#stage').innerHTML=`<div class="sgrid followdetailgrid${collection?' mixgrid':''}"><div class="vwrap followdetailmedia"><button class="closestage" id="closeStage" title="关闭" aria-label="关闭">${icon('x')}</button>${media}</div>+ ${collection?followQueueHtml(collection,item.id):''}<div class="side followdetailside">- <div class="stitle">${esc(item.title)}</div>- <div class="followdetailidentity"><span class="mav fsourceavatar">${followAuthorAvatar(source?[source]:[])}</span>- <div><b>${esc(author)}</b><span>${sourceIcon(item.provider)}${esc(item.provider_label)}</span></div></div>+ <div class="followdetailtitle"><div class="stitle">${esc(item.title)}</div>${item.url?`<a class="followorigin" href="${esc(item.url)}" target="_blank" rel="noreferrer noopener" title="打开来源页面" aria-label="打开来源页面">${icon('external-link')}</a>`:''}</div>+ <div class="followdetailidentity"><span class="mav fsourceavatar">${followAuthorAvatar(authorSources)}</span>+ <div><b>${esc(author)}</b>${postedBy?`<span>发布者 ${esc(postedBy)}</span>`:''}</div></div><div class="smeta mono"><span>${followWhen(item)}</span>${item.duration?`<span>${fmtDur(item.duration)}</span>`:''}${badges?`<span class="fbadges">${badges}</span>`:''}</div>${item.summary?`<p class="followdetailsummary">${esc(item.summary)}</p>`:''}${tags?`<div class="stags followdetailtags">${tags}</div>`:''}@@ -1405,13 +1407,20 @@ async function openFollowDetail(id,push=true){<div class="fb followdetailactions"><button class="later" data-follow-detail-save aria-label="${item.status==='saved'?'已保存':'保存到账本'}" title="${item.status==='saved'?'已保存':'保存到账本'}"${item.status==='saved'?' disabled':''}>${item.status==='saved'?icon('check'):icon('bookmark-plus')}</button><button class="seen" data-follow-detail-status="seen" aria-label="标记已看" title="标记已看" aria-pressed="${item.status==='seen'}">${icon('eye')}</button>- <button class="dislike" data-follow-detail-status="ignored" aria-label="忽略" title="忽略" aria-pressed="${item.status==='ignored'}">${icon('x')}</button>+ <button class="dislike" data-follow-detail-status="ignored" aria-label="忽略" title="忽略" aria-pressed="${item.status==='ignored'}">${icon('eye-off')}</button>${item.status==='seen'||item.status==='ignored'?`<button data-follow-detail-status="new" aria-label="恢复未看" title="恢复未看">${icon('rotate-ccw')}</button>`:''}</div><span class="fstate" aria-live="polite"></span>- ${item.url?`<a class="followorigin" href="${esc(item.url)}" target="_blank" rel="noreferrer noopener">${icon('external-link')}打开来源页面</a>`:''}</div></div>`;- const closeDetail=()=>{disposeStage(true);openFollow(false)};+ const closeDetail=async()=>{disposeStage(false);route(followDetailReturnPath||'/follow');await openFollow(false)};$('#closeStage').onclick=closeDetail;+ $('#stage').querySelectorAll('[data-follow-queue-close]').forEach(button=>button.onclick=closeDetail);+ $('#stage').querySelectorAll('[data-follow-queue-item]').forEach(button=>button.onclick=()=>+ openFollowDetail(+button.dataset.followQueueItem,true));+ $('#stage').querySelectorAll('.followdetailtags [data-follow-tag]').forEach(button=>button.onclick=async()=>{+ const tag=button.dataset.followTag;+ if(followTags.has(tag))followTags.delete(tag);else followTags.add(tag);+ await closeDetail();+ });const write=async(button,path,body,done)=>{const state=$('#stage').querySelector('.fstate');button.disabled=true;try{await api(path,{method:'POST',body:JSON.stringify(body)});done();state.textContent='已更新'}@@ -1453,7 +1462,7 @@ function followCard(group,authorSources=[]){<div class="factions"><button data-follow-save="${item.id}" title="${item.status==='saved'?'已保存':'保存到账本'}" aria-label="${item.status==='saved'?'已保存':'保存到账本'}"${item.status==='saved'?' disabled':''}>${item.status==='saved'?icon('check'):icon('bookmark-plus')}</button><button data-follow-status="${item.id}" data-to="seen" title="标记已看" aria-label="标记已看"${item.status==='seen'?' disabled':''}>${icon('eye')}</button>- <button data-follow-status="${item.id}" data-to="ignored" title="忽略" aria-label="忽略"${item.status==='ignored'?' disabled':''}>${icon('x')}</button>+ <button data-follow-status="${item.id}" data-to="ignored" title="忽略" aria-label="忽略"${item.status==='ignored'?' disabled':''}>${icon('eye-off')}</button>${item.status==='seen'||item.status==='ignored'?`<button data-follow-status="${item.id}" data-to="new" title="恢复未看" aria-label="恢复未看">${icon('rotate-ccw')}</button>`:''}</div></div></div><div class="meta"><span class="mav fsourceavatar" title="作者头像">${followAuthorAvatar(authorSources)}</span>@@ -1497,7 +1506,7 @@ function followCheckSummary(report){}/* ── 看的那一页 ── */-let followAuthor='',followProvider='',followTags=new Set(),followGroupsById=new Map(),followItemsById=new Map();+let followAuthor='',followProvider='',followTags=new Set(),followGroupByItemId=new Map(),followItemsById=new Map(),followDetailReturnPath='/follow';const TAGGED_PROVIDERS=['rule34video','rule34xxx'];function groupTagType(groups,tag){for(const group of groups){@@ -1513,22 +1522,29 @@ function renderFollow(){const broken=sources.filter(s=>s.last_status==='error'||s.last_status==='unauthorized');const byId=new Map(sources.map(source=>[source.id,source]));const sourceOf=group=>byId.get(group.primary&&group.primary.source_id);- const authorSources=new Map(),providers=new Map(),tagCounts=new Map();+ const authorSources=new Map(),activeAuthors=new Set(),providers=new Map(),tagCounts=new Map();+ sources.forEach(source=>{+ if(!source.author_key)return;+ if(!authorSources.has(source.author_key))authorSources.set(source.author_key,[]);+ authorSources.get(source.author_key).push(source);+ });groups.forEach(group=>{(group.primary&&group.primary.tags||[]).forEach(tag=>tagCounts.set(tag,(tagCounts.get(tag)||0)+1));const source=sourceOf(group);if(!source)return;- if(source.author_key){- if(!authorSources.has(source.author_key))authorSources.set(source.author_key,[]);- authorSources.get(source.author_key).push(source);- }+ if(source.author_key)activeAuthors.add(source.author_key);if(!providers.has(source.provider))providers.set(source.provider,source.provider_label);});- const authors=new Map([...authorSources].map(([key,list])=>[key,{+ const authors=new Map([...authorSources].filter(([key])=>activeAuthors.has(key)).map(([key,list])=>[key,{name:followAuthorName(list),sources:list,}]));- const topTags=[...tagCounts].sort((a,b)=>b[1]-a[1]).slice(0,20)- .map(([tag,n])=>[tag,tagLabel(tag),n]);+ const rankedTags=[...tagCounts].sort((a,b)=>b[1]-a[1]);+ const topTagRows=rankedTags.slice(0,20);+ followTags.forEach(tag=>{+ if(tagCounts.has(tag)&&!topTagRows.some(([key])=>key===tag))+ topTagRows.push([tag,tagCounts.get(tag)]);+ });+ const topTags=topTagRows.map(([tag,n])=>[tag,tagLabel(tag),n]);if(followAuthor&&!authors.has(followAuthor))followAuthor='';if(followProvider&&!providers.has(followProvider))followProvider='';followTags=new Set([...followTags].filter(tag=>tagCounts.has(tag)));@@ -1665,7 +1681,7 @@ function followAuthorGroups(sources){const SOURCE_ICONS={fanbox:'https://www.fanbox.cc/favicon.ico',patreon:'https://www.patreon.com/favicon.ico',- subscribestar:'https://subscribestar.adult/favicon.ico',+ subscribestar:'https://assets.subscribestar.com/assets/public/images/favicons/favicon-32x32-b9aa1e7e5bab6cb1b28b5161e16f9d42.png',kemono:'https://kemono.cr/assets/favicon-CPB6l7kH.ico',coomer:'https://coomer.st/assets/favicon-CPB6l7kH.ico',pawchive:'https://pawchive.pw/static/favicon.png',@@ -1678,19 +1694,26 @@ const sourceIcon=provider=>SOURCE_ICONS[provider]referrerpolicy="no-referrer" onerror="this.remove()">`: '';-/* 头像只有实测拿得到的来源才有(kemono 系)。取不到就显示站点缩写,- **不用首字母假装成头像**——那会让「没取到」看起来像「取到了」。 */+function followAvatarInitial(group){+ const name=followAuthorName(group).trim();+ const ascii=name.match(/[A-Za-z0-9]/);+ return (ascii?ascii[0]:Array.from(name)[0]||'?').toUpperCase();+}++/* 同一作者的官方来源优先提供头像,归档来源只回退。都取不到时明确用作者首字母,+ 不再从某条来源的中文显示标签切出“初”“一”之类与作者无关的字。 */function followAuthorAvatar(group){const official=group.find(source=>source.official_avatar_url);const mirror=group.find(source=>source.avatar_url);const src=official?.official_avatar_url||mirror?.avatar_url;const fallback=official&&mirror&&mirror.avatar_url!==src?mirror.avatar_url:'';- if(src)return `<img class="favatar" src="${esc(src)}" alt=""+ const initial=followAvatarInitial(group);+ if(src)return `<img class="favatar" src="${esc(src)}" alt="" data-initial="${esc(initial)}"${fallback?`data-fallback="${esc(fallback)}"`:''}loading="lazy" referrerpolicy="no-referrer" onerror="if(!this.dataset.f&&this.dataset.fallback){this.dataset.f='1';this.src=this.dataset.fallback}else{this.replaceWith(- Object.assign(document.createElement('span'),{className:'favatar none',textContent:'—'}))}">`;- return '<span class="favatar none" title="这些来源没有可取的头像">—</span>';+ Object.assign(document.createElement('span'),{className:'favatar none',textContent:this.dataset.initial}))}">`;+ return `<span class="favatar none" title="没有可用头像">${esc(initial)}</span>`;}/* 分组标题要用作者本人的名字,不是某一条来源的标签。`LazyProcrastinator · fanbox`@@ -1699,6 +1722,7 @@ function followAuthorAvatar(group){同名的几种写法里取大写最多的那个:`LazyProcrastinator` 比 `lazyprocrastinator`更像作者自己写的名字。 */function followAuthorName(group){+ if(!group.length)return '';const entity=group.find(source=>source.entity_name);if(entity)return entity.entity_name;const aliasGroup=(followData.author_aliases||[]).find(@@ -1854,11 +1878,11 @@ function renderFollowManage(credentials){<button class="fbtn primary" type="submit">查找</button></form><p class="fnote" data-follow-add-state aria-live="polite"></p>+ <div id="followPicks"></div>${(followData.suggestions||[]).length?`<div class="fguess"><span class="fmeta">猜你喜欢</span>${followSuggestionChips(followData.suggestions)}</div>`:''}${followAliasManager(followData.author_aliases,followData.alias_suggestions)}- <div id="followPicks"></div></section><section class="fsec"><div class="fsechead"><h3>关注列表</h3>@@ -1930,8 +1954,7 @@ function wireFollowItems(){event.stopPropagation();await followWrite(button,'/api/follow/save',{item:+button.dataset.followSave})});root.querySelectorAll('[data-follow-collection]').forEach(button=>button.onclick=event=>{- event.stopPropagation();const group=followGroupsById.get(+button.dataset.followCollection);- if(group)openFollowCollection(group)});+ event.stopPropagation();openFollowDetail(+button.dataset.followCollection)});root.querySelectorAll('.followitem[data-follow-item]').forEach(card=>{const id=+card.dataset.followItem;card.onclick=event=>{@@ -2140,6 +2163,7 @@ function renderFollowPicks(results){${total?`<div class="fpickactions"><button data-pick-add>添加选中</button><button data-pick-cancel>取消</button><span data-pick-state aria-live="polite"></span></div>`:'<div class="fpickactions"><button data-pick-cancel>关闭</button></div>'}</div>`;+ box.scrollIntoView({block:'nearest',behavior:'smooth'});box.querySelector('[data-pick-cancel]').onclick=()=>{box.innerHTML=''};const addButton=box.querySelector('[data-pick-add]');if(addButton)addButton.onclick=async()=>{diff --git a/web/index.html b/web/index.htmlindex bdaeb1c0d..a8cf0d9cf 100644--- a/web/index.html+++ b/web/index.html@@ -39,6 +39,7 @@<symbol id="i-thumbs-up" viewBox="0 0 24 24"><path d="M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"/><path d="M7 10v12"/></symbol><symbol id="i-thumbs-down" viewBox="0 0 24 24"><path d="M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"/><path d="M17 14V2"/></symbol><symbol id="i-eye" viewBox="0 0 24 24"><path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/></symbol>+ <symbol id="i-eye-off" viewBox="0 0 24 24"><path d="m2 2 20 20"/><path d="M6.71 6.71C4.82 8.06 3.23 9.91 2.06 11.65a1 1 0 0 0 0 .7C4.25 15.62 7.68 19 12 19c1.45 0 2.79-.38 4-.99"/><path d="M10.73 5.08A8.5 8.5 0 0 1 12 5c4.32 0 7.75 3.38 9.94 6.65a1 1 0 0 1 0 .7 16.7 16.7 0 0 1-2.05 2.5"/><path d="M14.12 14.12A3 3 0 0 1 9.88 9.88"/></symbol><!-- 图标库里没有表示广告的图形;按 Lucide 的 24×24 描边风格自绘一个感叹号圆标,线宽、圆角端点与其余图标一致,不至于在同一条导航里显得格格不入。 --><symbol id="i-alert" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 8v4"/><path d="M12 16h.01"/></symbol>@@ -101,7 +102,7 @@<div class="batchbar" id="batchbar" hidden><span id="batchCount">已选 0 项</span><button data-batch="like"><svg viewBox="0 0 24 24"><use href="#i-thumbs-up"/></svg>喜欢</button><button data-batch="seen"><svg viewBox="0 0 24 24"><use href="#i-eye"/></svg>看过</button><button data-batch="later"><svg viewBox="0 0 24 24"><use href="#i-bookmark-plus"/></svg>稍后看</button><button class="danger" data-batch="dispose"><svg viewBox="0 0 24 24"><use href="#i-trash"/></svg>加入回收站</button><button data-trash-only data-batch="restore"><svg viewBox="0 0 24 24"><use href="#i-rotate-ccw"/></svg>还原</button><button class="danger" data-trash-only data-batch="delete"><svg viewBox="0 0 24 24"><use href="#i-trash"/></svg>彻底删除</button>- <button id="followBatchAll" data-follow-control hidden><svg viewBox="0 0 24 24"><use href="#i-square-check-big"/></svg>全选当前</button><button data-follow-batch="save" hidden><svg viewBox="0 0 24 24"><use href="#i-bookmark-plus"/></svg>保存到账本</button><button data-follow-batch="seen" hidden><svg viewBox="0 0 24 24"><use href="#i-eye"/></svg>标记已看</button><button data-follow-batch="ignored" hidden><svg viewBox="0 0 24 24"><use href="#i-x"/></svg>忽略</button>+ <button id="followBatchAll" data-follow-control hidden><svg viewBox="0 0 24 24"><use href="#i-square-check-big"/></svg>全选当前</button><button data-follow-batch="save" hidden><svg viewBox="0 0 24 24"><use href="#i-bookmark-plus"/></svg>保存到账本</button><button data-follow-batch="seen" hidden><svg viewBox="0 0 24 24"><use href="#i-eye"/></svg>标记已看</button><button data-follow-batch="ignored" hidden><svg viewBox="0 0 24 24"><use href="#i-eye-off"/></svg>忽略</button><button id="batchClear"><svg viewBox="0 0 24 24"><use href="#i-x"/></svg>取消</button></div><div class="tok" id="tok" hidden>