Peach: Local-first video metadata scraper and media manager.
fix(follow): align controls and media classification
longmeidaoafbd615dfe2b
diff --git a/src/peach/follow_sources.py b/src/peach/follow_sources.pyindex e00546efd..22b1efd1c 100644--- a/src/peach/follow_sources.py+++ b/src/peach/follow_sources.py@@ -57,6 +57,8 @@ _FILE_HOST_DOMAINS = frozenset({})_LINK_RE = re.compile(r"https?://[^\s\"'<>)\]]+", re.IGNORECASE)+_F95_IMAGE_RE = re.compile(+ r"\.(?:avif|bmp|gif|jpe?g|png|webp)(?:$|[?#])", re.IGNORECASE)def resource_links(text: str | None) -> list[str]:@@ -73,6 +75,33 @@ def resource_links(text: str | None) -> list[str]:return found+def f95_attachment_media_items(metadata: Mapping[str, object]) -> list[dict[str, object]]:+ """Project F95 image attachments, including rows saved before galleries existed."""+ attachments = metadata.get("attachments")+ if not isinstance(attachments, list):+ return []+ result: list[dict[str, object]] = []+ for index, value in enumerate(attachments):+ url = str(value or "")+ try:+ parsed = urllib.parse.urlsplit(url)+ except ValueError:+ continue+ if (parsed.scheme != "https" or parsed.hostname != "attachments.f95zone.to"+ or not _F95_IMAGE_RE.search(url)):+ continue+ name = urllib.parse.unquote(parsed.path.rsplit("/", 1)[-1]) or f"image-{index + 1}"+ result.append({+ "id": f"f95-attachment-{index + 1}",+ "name": name,+ "media_kind": "image",+ "url": url,+ "thumb_url": url,+ "resource_provider": "f95zone",+ })+ return result++def _is_resource_url(url: str) -> bool:try:parsed = urllib.parse.urlsplit(url)@@ -1094,7 +1123,8 @@ class F95ZoneConnector(_BaseConnector):enriched = []for candidate in candidates:links = [str(value) for value in candidate.extra.get("links", [])]- media_items = self._gofile_media(links)+ image_items = f95_attachment_media_items(candidate.extra)+ media_items = tuple(image_items) + self._gofile_media(links)enriched.append(replace(candidate,extra={**dict(candidate.extra), "media_items": media_items,diff --git a/src/peach/follow_stream.py b/src/peach/follow_stream.pyindex ecd29ca03..9bb501623 100644--- a/src/peach/follow_stream.py+++ b/src/peach/follow_stream.py@@ -14,7 +14,7 @@ from dataclasses import dataclassfrom typing import Callable, Mappingfrom . import follow_providers-from .follow_sources import USER_AGENT+from .follow_sources import USER_AGENT, f95_attachment_media_itemsfrom .follow_secrets import Credentialfrom .follow_store import FollowItemRowfrom .http import HttpRequest, HttpTransport@@ -69,6 +69,9 @@ class FollowMediaResolver:if item.metadata.get("media_needs_credential"):raise FollowMediaUnavailable("媒体需要来源登录会话")media_items = item.metadata.get("media_items")+ if (not isinstance(media_items, list) or not media_items) \+ and item.provider == "f95zone":+ media_items = f95_attachment_media_items(item.metadata)if isinstance(media_items, list) and media_items:index = 0 if media_index is None else media_indexif index < 0 or index >= len(media_items):@@ -92,6 +95,10 @@ class FollowMediaResolver:if not _allowed_resource(url, ("fanbox.cc",)):raise FollowMediaUnavailable("FANBOX 返回了不受信任的图片地址")return ResolvedFollowMedia(url, item.url)+ if resource_provider == "f95zone":+ if not _allowed_resource(url, ("attachments.f95zone.to",)):+ raise FollowMediaUnavailable("F95 返回了不受信任的图片地址")+ return ResolvedFollowMedia(url, item.url)raise FollowMediaUnavailable("媒体来源不受支持")if item.provider != "rule34video":if not item.media_url or not _allowed(item.provider, item.media_url):diff --git a/src/peach/web_follow.py b/src/peach/web_follow.pyindex f59d4f4e4..2e86ab41c 100644--- a/src/peach/web_follow.py+++ b/src/peach/web_follow.py@@ -19,7 +19,7 @@ from .follow_discovery import discoverfrom .follow_secrets import CredentialError, CredentialStorefrom .follow_sources import (CONNECTORS, KemonoConnector, build_connector, canonical_source_ref,- parse_source_url, resource_links,+ f95_attachment_media_items, parse_source_url, resource_links,)from .follow_store import FollowStore, ReleaseGroupfrom .taste_history import read_creator_candidates@@ -131,8 +131,8 @@ def _video_media_type(value: object) -> str:def _media_items(item) -> list[dict]:"""给浏览器媒体序号和展示字段;真实上游 URL 仍只留在服务端 metadata。"""raw = item.metadata.get("media_items")- if not isinstance(raw, list):- return []+ if not isinstance(raw, list) or not raw:+ raw = f95_attachment_media_items(item.metadata) if item.provider == "f95zone" else []result = []for index, media in enumerate(raw):if not isinstance(media, dict):diff --git a/tests/test_follow_sources.py b/tests/test_follow_sources.pyindex 6f81c6be9..5774abbe8 100644--- a/tests/test_follow_sources.py+++ b/tests/test_follow_sources.py@@ -764,6 +764,10 @@ class F95ZoneConnectorTests(unittest.TestCase):self.assertEqual(candidate.extra["attachments"], ["https://attachments.f95zone.to/2026/08/6372325_preview.png",])+ self.assertEqual([item["media_kind"] for item in candidate.extra["media_items"]],+ ["image"])+ self.assertEqual(candidate.extra["media_items"][0]["resource_provider"],+ "f95zone")def test_inline_meme_without_a_file_resource_is_skipped(self):body = F95_HTML.replace(diff --git a/tests/test_follow_stream.py b/tests/test_follow_stream.pyindex ab55c78b6..eb58bdf2c 100644--- a/tests/test_follow_stream.py+++ b/tests/test_follow_stream.py@@ -65,6 +65,18 @@ class FollowMediaResolverTests(unittest.TestCase):target = FollowMediaResolver(lambda *_args: None).resolve(item, 1)self.assertEqual(target.url, "https://downloads.fanbox.cc/two.jpg")+ def test_legacy_f95_attachment_is_resolved_as_an_image(self):+ item = SimpleNamespace(+ id=13, provider="f95zone", url="https://f95zone.to/threads/1/post-13",+ media_url="https://pixeldrain.com/l/files", metadata={"attachments": [+ "https://attachments.f95zone.to/2026/08/one.jpg",+ ]},+ )+ target = FollowMediaResolver(lambda *_args: None).resolve(item, 0)+ self.assertEqual(target.url,+ "https://attachments.f95zone.to/2026/08/one.jpg")+ self.assertEqual(target.referer, item.url)+def test_gofile_media_keeps_the_token_in_the_proxy_header(self):item = SimpleNamespace(id=12, provider="fanbox", url="https://creator.fanbox.cc/posts/12",diff --git a/tests/test_follow_web.py b/tests/test_follow_web.pyindex f036db89b..eb998d593 100644--- a/tests/test_follow_web.py+++ b/tests/test_follow_web.py@@ -242,6 +242,25 @@ class FollowContractTests(unittest.TestCase):])self.assertNotIn("media_url", item)+ def test_legacy_f95_image_attachments_are_projected_without_a_ledger_write(self):+ self._seed(candidates=(FollowCandidate(+ provider="f95zone", external_id="21435167", title="Image set",+ url="https://f95zone.to/threads/160190/post-21435167",+ media_url="https://pixeldrain.com/l/verified",+ thumb_url="https://attachments.f95zone.to/2026/08/one.jpg",+ extra={"links": ["https://pixeldrain.com/l/verified"],+ "attachments": [+ "https://attachments.f95zone.to/2026/08/one.jpg",+ "https://attachments.f95zone.to/2026/08/two.png",+ ]},+ ),), provider="f95zone", ref="160190", semantics="release")+ item = self._get()["groups"][0]["primary"]+ self.assertEqual([media["media_kind"] for media in item["media_items"]],+ ["image", "image"])+ self.assertEqual(item["media_kind"], "image")+ self.assertTrue(item["playable"])+ self.assertTrue(all("url" not in media for media in item["media_items"]))+def test_media_collections_expose_only_safe_display_fields_and_indices(self):self._seed(candidates=(FollowCandidate(provider="fanbox", external_id="12228983", title="Poll Results",@@ -1213,6 +1232,10 @@ class FollowWebSourceTests(unittest.TestCase):rule = rule[:rule.index("}")]self.assertIn("height:38px", rule)self.assertIn("min-height:38px", rule)+ # 38px - 2px 边框 - 16px 内边距 = 20px 行高;textarea 会从内容区+ # 顶部排第一行,留下额外内容高度就会让文字视觉上偏上。+ self.assertIn("padding:8px 12px 8px 38px", rule)+ self.assertIn("line-height:20px", rule)button = page[page.index("\n.fbtn{"):]self.assertIn("height:32px", button[:button.index("}")])# faddform 里的按钮随输入栏同高(Geist 输入 32px 基线之上的一档)。@@ -1816,27 +1839,46 @@ class FollowWebSourceTests(unittest.TestCase):self.assertPageContains('data-follow-queue-item="${item.id}"')self.assertPageContains("openFollowDetail(+button.dataset.followCollection)")- def test_follow_reuses_media_tabs_and_keeps_mixed_updates_in_both_views(self):+ def test_follow_reuses_entity_media_buttons_and_offers_the_vercel_switch_variant(self):self.assertPageContains("const followMediaKinds=group=>")self.assertPageContains("function followItemMediaKinds(item)")self.assertPageContains("const item=followItemForMedia(group)")- self.assertPageContains('class="mediatabs followmediatabs"')+ 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("<span>视频</span>")- self.assertPageContains("<span>图片</span>")- self.assertPageContains("followMediaView=new URLSearchParams(location.search).get('media')==='images'?'images':'videos'")+ self.assertPageContains("followMediaUi=FOLLOW_MEDIA_UIS.has(params.get('media-ui'))")+ 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('class="mediatabs followmediatabs"'))+ watch.index('followMediaControl(mediaCounts)'))self.assertLess(watch.index('class="tagbar followfilters"'),- watch.index('class="mediatabs followmediatabs"'))+ watch.index('followMediaControl(mediaCounts)'))self.assertPageContains("followMediaView==='images'?' followphotowall':''")self.assertPageContains(".followlist.followphotowall{display:block;column-count:5")self.assertPageContains(".followitem.imagecard .followvisual .pic>img{position:relative")+ def test_external_file_pages_do_not_default_to_video_and_paging_actions_share_one_row(self):+ self.assertPageContains("else if(item.media_kind==='image'||item.media_kind==='video')kinds.add(item.media_kind)")+ self.assertPageLacks("else kinds.add(item.media_kind==='image'?'image':'video')")+ self.assertPageContains('class="followpagination"')+ self.assertPageContains("${icon('plus')}加载更多")+ self.assertPageContains("${icon('history')}抓更早的一页")+ self.assertPageContains("spinnerHtml('加载更多')")+ self.assertPageContains("loadingDotsHtml('抓取中…')")++ def test_follow_management_list_has_routed_sorting(self):+ self.assertPageContains('data-follow-sort aria-label="关注列表排序"')+ self.assertPageContains('<option value="checked"')+ self.assertPageContains('<option value="name"')+ self.assertPageContains('<option value="sources"')+ self.assertPageContains("followManageSort=['checked','name','sources'].includes(requested)?requested:'checked'")+ self.assertPageContains("return groups.sort((a,b)=>{")+def test_mix_and_follow_queues_stay_below_media_with_details_on_the_right(self):self.assertPageContains('grid-template-areas:"media side" "queue queue"')self.assertPageContains('.sgrid.mixgrid>.vwrap{grid-area:media}')diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex 805e180c0..e1f18bbb0 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -2015,7 +2015,7 @@ class WebUiSourceTests(unittest.TestCase):reviewed_end_selectors = {".alphatag span:first-of-type", ".av .nm", ".entitylinklabel",".fauthor .fsource.frow>b", ".fauthorhead b",- ".fchip", ".folderfoot .fmeta", ".fpickactions [data-pick-state]",+ ".fchip", ".followpageaction .fmeta", ".fpickactions [data-pick-state]",".frow>b", ".fvkind", ".idname", ".kv>span:first-child",".meta .t", ".meta .who", ".mixcopy b,.mixcopy span",".mixitemtext [data-truncate-end]", ".mixqueuehead h2",diff --git a/web/app.css b/web/app.cssindex 82a1c7c91..428d3c8c8 100644--- a/web/app.css+++ b/web/app.css@@ -1724,7 +1724,6 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位.follow{padding:4px 0 42px}.followhead{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-bottom:14px}.followhead .pagetitle{margin:0}-.followmediatabs{margin:2px 0 18px}.follow .fcheck{font-weight:600}.follow .fcheck svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:2}.followauthors{padding:3px 0 10px;margin:0 0 2px;overscroll-behavior-inline:contain}@@ -1740,6 +1739,17 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位.followfilters .pill .n{margin-left:5px;color:inherit}.followfilters .sourcepill{width:40px;padding:0}.followfilters .sourcepill .ficon{width:21px;height:21px;margin:0}+.followmediaicons{display:inline-flex;align-items:center;gap:2px;flex:none}+.followmediaicons .entitymediatoggle{display:grid;place-items:center;flex:0 0 32px;width:32px;height:32px;padding:0;+ border:0;border-radius:var(--control-radius);background:transparent;color:var(--muted);cursor:pointer}+.followmediaicons .entitymediatoggle svg{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:2}+.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}@@ -1847,6 +1857,10 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位.dupactions.fsechead button:hover{border-color:var(--tungsten);color:var(--tungsten)}.fsechead h3{margin:0;font-size:var(--fs-md);font-weight:600;letter-spacing:.01em}.fsechead .fmeta{flex:1 1 auto}+.fmanagesort{display:inline-flex;align-items:center;gap:7px;color:var(--muted);font-size:var(--fs-xs)}+.fmanagesort select{height:32px;padding:0 28px 0 10px;border:1px solid var(--border-15);border-radius:var(--control-radius);+ background:var(--surface);color:var(--ink-2);font:inherit;font-size:var(--fs-sm);color-scheme:dark;cursor:pointer}+.fmanagesort select:focus-visible{outline:2px solid var(--tungsten);outline-offset:2px}.fmeta{font-size:var(--fs-xs);color:var(--muted)}.fmeta b{color:var(--ink);font-variant-numeric:tabular-nums}.fmeta.warn{color:var(--drop)}@@ -1944,7 +1958,7 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位.fsearchprefix>svg{width:16px;height:16px;stroke:currentColor;fill:none}.faddform textarea{width:100%;flex:1 1 auto;min-width:0;height:38px;min-height:38px;max-height:220px;box-sizing:border-box;border:1px solid var(--border-15);border-radius:6px;- background:var(--ground);color:var(--ink);padding:5px 12px 5px 38px;font-size:var(--fs-md);font-family:inherit;+ background:var(--ground);color:var(--ink);padding:8px 12px 8px 38px;font-size:var(--fs-md);font-family:inherit;line-height:20px;resize:none;overflow-y:auto;overflow-x:hidden;transition:border-color .12s ease}.faddform .fbtn{height:38px;min-height:38px}.faddform textarea::placeholder{color:var(--muted)}@@ -2137,15 +2151,13 @@ details.fcred{display:block}.fpickactions [data-pick-state]{display:flex;align-items:center;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:var(--fs-xs);color:var(--muted)}-/* 关注页底部的「往回抓」。放在列表末尾而不是顶部:它的语义是「这些之外还有更早的」,- 顶部会让人以为是刷新。 */-.folderfoot{display:flex;align-items:center;gap:12px;min-width:0;white-space:nowrap;margin:18px 0 0;- padding-top:14px;border-top:1px solid var(--line-soft)}-/* 「加载更多」和「抓更早的一页」是两件事:前者翻本地已有的条目,- 后者去站点上要更早的。版式共用一套,语义不同不合并。 */-.followmore{display:flex;align-items:center;gap:12px;margin:18px 0 0;- padding-top:14px;border-top:1px solid var(--line-soft)}-.folderfoot .fmeta{min-width:0;margin-left:0;overflow:hidden;text-overflow:ellipsis}+/* 关注页底部:两个翻页动作同属列表末尾,放在一条底栏;+ 按钮仍保留各自的本地加载 / 站点抓取语义。 */+.followpagination{display:flex;align-items:center;gap:14px 24px;min-width:0;margin:18px 0 0;+ padding-top:14px;border-top:1px solid var(--line-soft);white-space:nowrap;overflow-x:auto;scrollbar-width:thin}+.followpageaction{display:inline-flex;align-items:center;gap:12px;min-width:0;flex:none}+.followpageaction .fmeta{min-width:0;overflow:hidden;text-overflow:ellipsis}+@media(max-width:640px){.followpagination{align-items:flex-start;flex-wrap:wrap;white-space:normal}.followpageaction{width:100%}}/* 资源标识统一由 MiddleTruncate 计算可见文本。星号让本规则与「类 + 元素」的末尾省略选择器同权重,并凭源码顺序覆盖,避免两套省略同时生效。 */diff --git a/web/app.js b/web/app.jsindex 6bc829975..c63dcbe98 100644--- a/web/app.js+++ b/web/app.js@@ -2195,7 +2195,7 @@ async function openQualityGoals(push=true){- `/follow-manage`(管理区)是**管**:加来源、检查更新、移除来源、看凭据状态,以及对内容做批量标记。联网只发生在管理页点「检查更新」的那一刻——看的那一页不联网。 */-let followData=null,followRuntime=null,followFilter='new',followBusy=false;+let followData=null,followRuntime=null,followFilter='new',followBusy=false,followManageSort='checked';/* 来源筛选:fsrcProviders 记录见过的全部来源(默认全选),fsrcUnchecked 只记被取消勾选的——新来源自动进入「全选」。 */const fsrcProviders=new Set(),fsrcUnchecked=new Set();@@ -2297,15 +2297,15 @@ function followVideoItems(group){item.playable&&item.media_kind==='video');}-/* 关注条目和资料页的作品不是同一种 DTO,但媒体 Tab 的语义相同:一个卡片只要- 含对应媒体就进入对应视图。旧的外部文件页没有可判定图片类型,继续留在默认的- 视频视图,避免加 Tab 后把原本可见的待解析更新悄悄藏掉。 */+/* 关注条目和资料页的作品不是同一种 DTO,但媒体切换的语义相同:一个卡片只要+ 含对应媒体就进入对应视图。external 只说明有外部文件页,不能再冒充视频;+ 没有可验证媒体类型的旧行不进入任一媒体视图。 */function followItemMediaKinds(item){const kinds=new Set();const embedded=item.media_items||[];if(embedded.length)embedded.forEach(media=>{if(media.media_kind==='image'||media.media_kind==='video')kinds.add(media.media_kind)});- else kinds.add(item.media_kind==='image'?'image':'video');+ else if(item.media_kind==='image'||item.media_kind==='video')kinds.add(item.media_kind);return kinds;}const followMediaKinds=group=>{@@ -2638,7 +2638,26 @@ function followCheckFailNote(report){}/* ── 看的那一页 ── */-let followAuthor='',followProvider='',followTags=new Set(),followMediaView='videos',followGroupByItemId=new Map(),followItemsById=new Map(),followDetailReturnPath='/follow';+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']);+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>+ <button class="entitymediatoggle" type="button" data-follow-media="images" aria-pressed="${followMediaView==='images'}"+ aria-label="图片 ${counts.images.toLocaleString()}" title="图片 ${counts.images.toLocaleString()}">${icon('pics')}</button></div>`;+}function groupTagType(groups,tag){for(const group of groups){const type=group.primary&&group.primary.tag_types&&group.primary.tag_types[tag];@@ -2690,8 +2709,10 @@ function renderFollow(){const mediaCounts={videos:0,images:0};filtered.forEach(group=>followMediaKinds(group).forEach(kind=>mediaCounts[kind==='image'?'images':'videos']++));+ const requestedMediaView=followMediaView;if(followMediaView==='images'&&!mediaCounts.images)followMediaView='videos';if(followMediaView==='videos'&&!mediaCounts.videos&&mediaCounts.images)followMediaView='images';+ if(requestedMediaView!==followMediaView&&location.pathname==='/follow')route(followViewPath(),true);const wantedKind=followMediaView==='images'?'image':'video';const visible=filtered.filter(group=>followMediaKinds(group).has(wantedKind));const providerPills=[...providers].map(([key,label])=>@@ -2708,15 +2729,12 @@ function renderFollow(){<div class="tagbar followfilters" aria-label="关注筛选">${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])=>`<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>- ${mediaCounts.images?`<div class="mediatabs followmediatabs" aria-label="关注媒体类型">- <button data-follow-media="videos" aria-pressed="${followMediaView==='videos'}">${icon('play')}<span>视频</span><b class="mono">${mediaCounts.videos.toLocaleString()}</b></button>- <button data-follow-media="images" aria-pressed="${followMediaView==='images'}">${icon('layout-grid')}<span>图片</span><b class="mono">${mediaCounts.images.toLocaleString()}</b></button>- </div>`:''}${broken.length&&!sessionStorage.getItem('peach-fwarn-dismissed')?`<p class="geist-banner fwarn">${icon('alert')}<span>${broken.length} 个来源上次检查失败,去<button class="flink" data-follow-manage>管理关注</button>看原因。</span><button class="wclose" data-fwarn-dismiss title="本次会话不再显示" aria-label="关闭提醒">${icon('x')}</button></p>`:''}<div class="followlist${followMediaView==='images'?' followphotowall':''}">${visible.length?visible.map(group=>{@@ -2725,12 +2743,11 @@ function renderFollow(){:groups.length?emptyState('layout-grid','当前筛选下没有更新','切换媒体类型、作者、来源或标签后再试。'):sources.length?emptyState('rss','没有符合条件的更新','切换状态或来源筛选后再试。'):emptyState('rss','还没有关注任何来源','添加作者或订阅来源后,更新会集中显示在这里。',{actions:'<button class="fbtn primary" data-follow-manage>添加关注</button>'})}</div>- ${followData.has_more?`<div class="followmore">- <button class="fbtn" data-follow-more>${icon('refresh-cw')}加载更多</button>- <span class="fmeta">已显示 ${visible.length.toLocaleString()} 项</span></div>`:''}- ${sources.some(source=>source.can_backfill)?`<div class="folderfoot">- <button class="fbtn" data-follow-older>${icon('refresh-cw')}抓更早的一页</button>- <span class="fmeta">${esc(followBackfillState(sources))}</span></div>`:''}</div>`;+ ${followData.has_more||sources.some(source=>source.can_backfill)?`<div class="followpagination">+ ${followData.has_more?`<span class="followpageaction"><button class="fbtn" data-follow-more>${icon('plus')}加载更多</button>+ <span class="fmeta">已显示 ${visible.length.toLocaleString()} 项</span></span>`:''}+ ${sources.some(source=>source.can_backfill)?`<span class="followpageaction"><button class="fbtn" data-follow-older>${icon('history')}抓更早的一页</button>+ <span class="fmeta">${esc(followBackfillState(sources))}</span></span>`:''}</div>`:''}</div>`;const more=$('#stats').querySelector('[data-follow-more]');if(more)more.onclick=()=>loadMoreFollow(more);wireFollowItems();@@ -2742,9 +2759,10 @@ function renderFollow(){followFilter=button.dataset.followFilter;openFollow(false)});$('#stats').querySelectorAll('[data-follow-media]').forEach(button=>button.onclick=()=>{followMediaView=button.dataset.followMedia;- route('/follow'+(followMediaView==='images'?'?media=images':''));renderFollow()});+ route(followViewPath());renderFollow()});$('#stats').querySelectorAll('[data-follow-author]').forEach(button=>button.onclick=()=>{- followAuthor=followAuthor===button.dataset.followAuthor?'':button.dataset.followAuthor;renderFollow()});+ followAuthor=followAuthor===button.dataset.followAuthor?'':button.dataset.followAuthor;+ route(followViewPath());renderFollow()});$('#stats').querySelectorAll('[data-follow-provider]').forEach(button=>button.onclick=()=>{followProvider=followProvider===button.dataset.followProvider?'':button.dataset.followProvider;renderFollow()});$('#stats').querySelectorAll('[data-follow-tag]').forEach(button=>button.onclick=()=>{@@ -2795,9 +2813,13 @@ function wireFollowOlder(){async function openFollow(push=true,renderForDetail=false){releaseHoverPreviews();disposeStage(false);document.body.classList.remove('entity-open','index-open');- if(push){followMediaView='videos';route('/follow')}- else if(location.pathname==='/follow')- followMediaView=new URLSearchParams(location.search).get('media')==='images'?'images':'videos';+ if(push){followAuthor='';followMediaView='videos';followMediaUi='buttons';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='';$('#count').textContent='';$('#loadSentinel').hidden=true;$('#shortsSec').hidden=true;@@ -2832,7 +2854,14 @@ function followAuthorGroups(sources){if(!byKey.has(key)){byKey.set(key,[]);order.push(key)}byKey.get(key).push(source);});- return order.map(key=>byKey.get(key));+ const groups=order.map(key=>byKey.get(key));+ const name=group=>followAuthorName(group);+ const checked=group=>Math.max(...group.map(source=>Date.parse(source.last_checked_at||'')||0));+ return groups.sort((a,b)=>{+ if(followManageSort==='name')return name(a).localeCompare(name(b),'zh-CN',{numeric:true});+ if(followManageSort==='sources')return b.length-a.length||name(a).localeCompare(name(b),'zh-CN',{numeric:true});+ return checked(b)-checked(a)||name(a).localeCompare(name(b),'zh-CN',{numeric:true});+ });}/* 这些地址来自各站实际声明的图标;内容哈希变更或站点拒绝外链时退回纯文字。 */@@ -3056,6 +3085,11 @@ function renderFollowManage(credentials){<div class="fsechead"><h3>关注列表</h3><span class="fmeta">${sources.length} 个来源${counts.new?` · <b>${counts.new}</b> 条未看`:''}</span>+ <label class="fmanagesort"><span>排序</span><select data-follow-sort aria-label="关注列表排序">+ <option value="checked"${followManageSort==='checked'?' selected':''}>最近检查</option>+ <option value="name"${followManageSort==='name'?' selected':''}>作者名称</option>+ <option value="sources"${followManageSort==='sources'?' selected':''}>来源数量</option>+ </select></label><button class="fbtn" data-follow-check=""${sources.length?'':' disabled'}>${icon('refresh-cw')}检查全部</button><button class="fbtn" data-follow-view>${icon('rss')}去看更新</button></div>@@ -3096,7 +3130,11 @@ function renderFollowManage(credentials){async function openFollowManage(push=true){releaseHoverPreviews();disposeStage(false);document.body.classList.remove('entity-open','index-open');- if(push)route('/follow-manage');+ if(push){followManageSort='checked';route('/follow-manage')}+ else if(location.pathname==='/follow-manage'){+ const requested=new URLSearchParams(location.search).get('sort');+ followManageSort=['checked','name','sources'].includes(requested)?requested:'checked';+ }const surface=claimSurface('/follow-manage');buildManageBar();$('#stats').hidden=false;$('#index').hidden=true;$('#grid').innerHTML='';@@ -3142,6 +3180,12 @@ function wireFollowItems(){function wireFollowManage(){const root=$('#stats'),form=root.querySelector('#followAdd');+ const sort=root.querySelector('[data-follow-sort]');+ if(sort)sort.onchange=()=>{+ followManageSort=sort.value;+ route('/follow-manage'+(followManageSort==='checked'?'':'?sort='+encodeURIComponent(followManageSort)));+ openFollowManage(false);+ };renderFollowSrcFilter(root.querySelector('#followSrcFilter'));const tooltipTrigger=root.querySelector('[data-fdesc-tooltip]');const tooltip=root.querySelector('#follow-credential-tooltip');