Peach: Local-first video metadata scraper and media manager.
fix(follow): honor source tag taxonomy and loading layout
longmeidao166301b289c5
diff --git a/.claude/skills/peach-web-ui/SKILL.md b/.claude/skills/peach-web-ui/SKILL.mdindex ea6472d01..91e2f7c0a 100644--- a/.claude/skills/peach-web-ui/SKILL.md+++ b/.claude/skills/peach-web-ui/SKILL.md@@ -43,8 +43,9 @@ description: 在新增、修改或复核 Peach 页面、控件、提示、错误- Progress 必须有真实 `value/max`、可见单位与 `aria-valuemin/max/now`;分隔线放在完整指标(含进度条)之后。- Switch 必须共享 radio `name`、初始一个 `checked`、键盘可用;布尔状态继续使用 Toggle。- 菜单每项包含与入口相同的图标和文字,菜单内部滚动、`overscroll-behavior:contain`,不得把浏览器页面撑出滚动条。-- Spinner 只反馈用户直接触发的动作,触发器声明 `aria-busy` 且等待时保持可聚焦;未知时长的后台抓取使用 Loading Dots。整页或大区块首次取数使用 Skeleton 预留最终结构。三者都必须保留可读状态文字并尊重 reduced motion。+- Spinner 只反馈用户直接触发的动作,触发器声明 `aria-busy` 且等待时保持可聚焦;未知时长的后台抓取使用 Loading Dots。整页或大区块首次取数使用 Skeleton 预留最终结构。Spinner/Loading Dots 保留可见状态文字;Skeleton 只保留给辅助技术的状态名,不另画「正在读取」文案。三者都尊重 reduced motion。- 同一次页面进入只呈现一段等待态;深链启动与页面取数复用同一个 Skeleton,禁止 Spinner 再切换成 Loading Dots 或 Skeleton。+- Skeleton 只覆盖真正等待的内容区;静态标题、导航和能同步得到的筛选控件立即显示。骨架必须复用最终容器的宽度、列数与对齐方式:卡片网格横向铺满,居中面板仍居中,不得用一列通用占位替代不同页面结构。- 分页末尾、空页和“没有更多内容”是中性终止状态,用可关闭 Note;只有需要恢复或处理的故障才能进入红色 error Note。- 弹层标题栏与滚动正文分层:标题分隔线属于卡片全宽,滚动条只属于正文。- 没有直接证据不得新增动效;参考产品无动画的菜单保持无动画。diff --git a/src/peach/follow_sources.py b/src/peach/follow_sources.pyindex d421d3b81..edeb75213 100644--- a/src/peach/follow_sources.py+++ b/src/peach/follow_sources.py@@ -870,6 +870,8 @@ class Rule34VideoConnector(_BaseConnector):for category in categories:tag_types[category] = ("metadata" if category.casefold() in {"2d", "3d"} else "copyright")+ for model in models:+ tag_types[model] = "artist"published = _iso_from_text(video.get("uploadDate"))return {"title": plain_text(video.get("name")),@@ -945,11 +947,14 @@ class Rule34XxxConnector(_BaseConnector):posts = payload.get("post", []) if isinstance(payload, dict) else payloadif not isinstance(posts, list):raise FollowSourceError("rule34xxx 的帖子列表格式不符")- candidates = tuple(- self._candidate(post, tag)- for post in posts[: self.max_items]- if isinstance(post, dict)- )+ candidates = []+ for post in posts[: self.max_items]:+ if not isinstance(post, dict):+ continue+ post_id = str(post.get("id") or "")+ tag_types = self._detail_tag_types(post_id) if post_id else {}+ candidates.append(self._candidate(post, tag, tag_types=tag_types))+ candidates = tuple(candidates)if page and not candidates:raise FollowHistoryEnd("没有更多历史内容")return SourceFetch(candidates=candidates, raw_body=response.body, **common)@@ -960,7 +965,44 @@ class Rule34XxxConnector(_BaseConnector):"tagme", "highres", "absurdres",})- def _candidate(self, post: dict, tag: str) -> FollowCandidate:+ def _detail_tag_types(self, post_id: str) -> dict[str, str]:+ """Read rule34.xxx's own tag taxonomy from the public post page.++ The posts DAPI only returns one flat tag string. The post page is the+ authoritative surface that marks each tag as general, artist,+ copyright, character or metadata. If that optional enrichment is+ unavailable we keep the post, but we do not guess types from words.+ """+ url = ("https://rule34.xxx/index.php?page=post&s=view&id="+ f"{urllib.parse.quote(post_id)}")+ try:+ response = self._get(url, headers={"Accept": "text/html"})+ except FollowSourceError:+ return {}+ if response.status != 200:+ return {}+ soup = BeautifulSoup(response.body, "html.parser")+ allowed = {"general", "artist", "copyright", "character", "metadata"}+ result: dict[str, str] = {}+ for row in soup.select("#tag-sidebar li[class*='tag-type-']"):+ tag_type = next((+ value.removeprefix("tag-type-") for value in row.get("class", [])+ if value.startswith("tag-type-")+ ), "")+ if tag_type not in allowed:+ continue+ link = row.select_one("a[href*='page=post'][href*='tags=']")+ if link is None:+ continue+ query = urllib.parse.parse_qs(+ urllib.parse.urlsplit(str(link.get("href") or "")).query)+ name = html.unescape(str((query.get("tags") or [""])[0])).strip()+ if name:+ result[name] = tag_type+ return result++ def _candidate(self, post: dict, tag: str, *,+ tag_types: Mapping[str, str] | None = None) -> FollowCandidate:post_id = str(post.get("id") or "")# dapi 返回的标签是 HTML 转义形态(实测 `miqo'te`)。实体不反转义# 就进 metadata,读取层再转一次就成了双重转义,用户看到的就是 `'`@@ -1005,7 +1047,8 @@ class Rule34XxxConnector(_BaseConnector):title_is_name=title_is_name,extra={"tag": tag, "tags": tags, "score": post.get("score"),"source": source, "title_from": title_from,- "preview_url": post.get("preview_url")},+ "preview_url": post.get("preview_url"),+ **({"tag_types": dict(tag_types)} if tag_types else {})},)@classmethoddiff --git a/src/peach/web_follow.py b/src/peach/web_follow.pyindex 95cf4eeea..7dcba2d68 100644--- a/src/peach/web_follow.py+++ b/src/peach/web_follow.py@@ -50,18 +50,14 @@ MAX_ITEM_TAGS = 24RULE34VIDEO_EXCLUDED_IDS = frozenset({"4533145"})# 内容筛选不让载体/渲染方式挤掉动作、角色与作品标签。原始 metadata 仍完整保留。-LOW_VALUE_FOLLOW_TAGS = frozenset({- "2d", "3d", "2d_animation", "3d_animation", "animated", "animation",+LOW_VALUE_GENERAL_TAGS = frozenset({"video", "tagme", "sound","no sound", "audio", "loop", "webm", "mp4",})-# 关注页的标签是「里面发生了什么」,不是人物计数、身体部位、画幅、年份、软件或-# 作品题材。原始 metadata 仍完整保留;这里只收窄卡片、详情、筛选条与在线标签页-# 共用的可见投影。Rule34.xxx 不提供 tag type,所以截图里这些漏项还需要形态判据。-NON_CONTENT_FOLLOW_TAG_TYPES = frozenset({- "artist", "character", "copyright", "metadata",-})+# 关注页的标签是「里面发生了什么」,不是人物计数、身体部位、画幅、年份或场景。+# 来源类型是第一道门槛:只有来源明确标成 general 的标签才会走到这里;形态判据+# 只负责 general 内部的通用词清理,绝不能拿它猜 artist/metadata 等来源类型。_NON_CONTENT_FOLLOW_TAG_RE = re.compile(r"^(?:"r"(?:19|20)\d{2}|\d{1,2}:\d{1,2}|"@@ -73,11 +69,9 @@ _NON_CONTENT_FOLLOW_TAG_RE = re.compile(r"(?:blonde|black|white|long|short)[_\s-](?:hair|female)|"r"(?:blue|green|brown)[_\s-]eyes|light[_\s-]skin|"r"(?:shorter|longer)[_\s-]than[_\s-]\d+[_\s-]seconds|short[_\s-]video|"- r"beach|initial[_\s-]?a|square[_\s-]?enix|"- r"final[_\s-]?fantasy(?:[_\s-].*)?|dead[_\s-]?or[_\s-]?alive(?:[_\s-].*)?"+ r"beach"r")$", re.I,)-_TOPICAL_FOLLOW_TAG_RE = re.compile(r"\([^)]+\)\s*$")_IMAGE_MEDIA_RE = re.compile(r"\.(?:avif|gif|jpe?g|png|webp)(?:$|[?#])", re.I)_VIDEO_MEDIA_RE = re.compile(r"\.(?:m4v|mov|mp4|og[gv]|webm)(?:/)?(?:$|[?#])", re.I)@@ -86,8 +80,47 @@ _RULE34XXX_PREVIEW_RE = re.compile(r"([0-9a-f]{32})\.jpg(?:[?#].*)?$", re.I)+def _item_all_tags(item) -> list[str]:+ """Return every recorded source tag once, preserving source spelling."""+ raw = item.metadata.get("tags")+ if isinstance(raw, str):+ values = raw.split()+ elif isinstance(raw, list):+ values = [str(value).strip() for value in raw if str(value).strip()]+ else:+ values = []+ for field in ("categories", "models"):+ recorded = item.metadata.get(field)+ if isinstance(recorded, list):+ values.extend(str(value).strip() for value in recorded if str(value).strip())+ seen, result = set(), []+ for value in values:+ tag = html.unescape(value)+ key = tag.casefold()+ if not tag or key in seen:+ continue+ seen.add(key)+ result.append(tag)+ return result+++def _recorded_tag_type(item, tag: str) -> str:+ raw = item.metadata.get("tag_types")+ if not isinstance(raw, dict):+ return ""+ value = raw.get(tag)+ if value is None:+ key = tag.casefold()+ value = next((candidate for name, candidate in raw.items()+ if html.unescape(str(name)).casefold() == key), None)+ tag_type = str(value or "").casefold()+ return tag_type if tag_type in {+ "artist", "character", "copyright", "metadata", "general"+ } else ""++def _item_tags(item) -> list[str]:- """条目的真实标签。+ """条目的内容标签。rule34.xxx 存空格分隔标签;Rule34Video 详情页存保留空格的标签列表和分类列表。kemono 系与 f95zone 的列表接口不给标签,所以它们是空列表。@@ -98,32 +131,15 @@ def _item_tags(item) -> list[str]:去掉作者手柄本身:按作者筛已经有专门的筛选条,标签里再出现一次没有信息量。"""- raw = item.metadata.get("tags")- if isinstance(raw, str):- values = raw.split()- elif isinstance(raw, list):- values = [str(value).strip() for value in raw if str(value).strip()]- else:- values = []- categories = item.metadata.get("categories")- if isinstance(categories, list):- values.extend(str(value).strip() for value in categories if str(value).strip())- values = [html.unescape(value) for value in values]+ values = _item_all_tags(item)subject = html.unescape(str(item.metadata.get("tag") or "")).casefold()- category_keys = {- html.unescape(str(value)).casefold()- for value in categories or []- } if isinstance(categories, list) else set()- recorded_types = item.metadata.get("tag_types")- recorded_types = recorded_types if isinstance(recorded_types, dict) else {}seen, tags = set(), []for tag in values:key = tag.casefold()- tag_type = str(recorded_types.get(tag) or recorded_types.get(key) or "general").casefold()- if (key == subject or key in seen or key in LOW_VALUE_FOLLOW_TAGS- or key in category_keys or tag_type in NON_CONTENT_FOLLOW_TAG_TYPES- or _NON_CONTENT_FOLLOW_TAG_RE.fullmatch(tag.strip())- or _TOPICAL_FOLLOW_TAG_RE.search(tag)):+ # 来源没给类型时宁可暂不放进卡片,也不把 unknown 猜成 general。+ if (_recorded_tag_type(item, tag) != "general"+ or key == subject or key in seen or key in LOW_VALUE_GENERAL_TAGS+ or _NON_CONTENT_FOLLOW_TAG_RE.fullmatch(tag.strip())):continueseen.add(key)tags.append(tag)@@ -133,13 +149,8 @@ def _item_tags(item) -> list[str]:def _item_tag_types(item, tags: list[str]) -> dict[str, str]:- raw = item.metadata.get("tag_types")- recorded = raw if isinstance(raw, dict) else {}- allowed = {"artist", "character", "copyright", "metadata", "general"}- return {- tag: (str(recorded.get(tag)) if str(recorded.get(tag)) in allowed else "general")- for tag in tags- }+ return {tag: tag_type for tag in tags+ if (tag_type := _recorded_tag_type(item, tag))}def _media_kind(item) -> str:@@ -274,6 +285,7 @@ def _excluded_item(item) -> bool:def _item_payload(item) -> dict:tags = _item_tags(item)+ detail_tags = _item_all_tags(item)media_kind = _media_kind(item)media_items = _media_items(item)if media_items:@@ -319,7 +331,8 @@ def _item_payload(item) -> dict:# 只投影连接器已验证过的文件页域名;原始媒体 URL 仍不进入 feed。"resource_urls": safe_resource_urls,"tags": tags,- "tag_types": _item_tag_types(item, tags),+ "detail_tags": detail_tags,+ "tag_types": _item_tag_types(item, detail_tags),}@@ -353,14 +366,17 @@ def _normalized_author_name(value: str, *, provider: str = "") -> str:return _AUTHOR_NOISE_RE.sub("", stripped.casefold())+def _author_display_text(value: str) -> str:+ """Remove container/service wording that is not part of an author name."""+ stripped = _LABEL_SERVICE_RE.sub("", str(value or "").strip())+ return _F95_TITLE_SUFFIX_RE.sub("", stripped).strip()++def _author_display_name(row) -> str:"""Return the readable author spelling carried by one follow source."""if row["entity_id"] and row["entity_name"]:return str(row["entity_name"])- label = _LABEL_SERVICE_RE.sub("", str(row["label"] or row["ref"] or "").strip())- if str(row["provider"] or "") == "f95zone":- label = _F95_TITLE_SUFFIX_RE.sub("", label)- return label.strip()+ return _author_display_text(row["label"] or row["ref"] or "")def _source_metadata(row) -> dict:@@ -410,7 +426,9 @@ def _follow_alias_state(connection) -> tuple[dict[str, str], list[dict]]:canonical_key = str(row["canonical_key"])group = groups.setdefault(canonical_key, {"canonical_key": canonical_key,- "canonical_name": str(row["canonical_name"]),+ # 旧别名记录可能把 F95 的容器标题保存成规范显示名;只修正读投影,+ # 不在这个只读接口里偷偷改真实表。+ "canonical_name": _author_display_text(row["canonical_name"]),"aliases": [],})if str(row["alias_key"]) != canonical_key:diff --git a/tests/test_follow_sources.py b/tests/test_follow_sources.pyindex c43a63aa7..f0347a6d2 100644--- a/tests/test_follow_sources.py+++ b/tests/test_follow_sources.py@@ -78,6 +78,14 @@ RULE34VIDEO_DETAIL_HTML = b"""<html><body><script>video_url: 'https://rule34video.com/get_file/51/aa/4542721.mp4/?v-acctoken=test'</script></body></html>"""+RULE34XXX_DETAIL_HTML = b"""<html><body><ul id="tag-sidebar">+<li class="tag-type-metadata tag"><a href="index.php?page=wiki&s=list&search=3d">?</a><a href="index.php?page=post&s=list&tags=3d">3d</a></li>+<li class="tag-type-metadata tag"><a href="index.php?page=wiki&s=list&search=blender">?</a><a href="index.php?page=post&s=list&tags=blender">blender</a></li>+<li class="tag-type-metadata tag"><a href="index.php?page=wiki&s=list&search=3d_model">?</a><a href="index.php?page=post&s=list&tags=3d_model">3d model</a></li>+<li class="tag-type-artist tag"><a href="index.php?page=post&s=list&tags=lazyprocrastinator">lazyprocrastinator</a></li>+<li class="tag-type-general tag"><a href="index.php?page=post&s=list&tags=reverse_cowgirl_position">reverse cowgirl position</a></li>+</ul></body></html>"""+F95_HTML = b"""<html><head><title>Collection - Video - Lazy | F95zone</title></head><body><h1 class="p-title-value"><span class="label">Collection</span><span class="label">Video</span>Lazy Procrastinator Collection [2026-06-28] [LazyProcrastinator/LazyProcrast]</h1>@@ -871,6 +879,26 @@ class Rule34XxxConnectorTests(unittest.TestCase):self.assertNotIn("api_key", result.request_url)self.assertNotIn("sekret", result.request_url)+ def test_post_page_taxonomy_is_recorded_without_guessing_from_tag_words(self):+ seen = []+ def transport(request, timeout, max_bytes):+ seen.append(request)+ body = RULE34XXX_JSON if request.url.startswith("https://api.rule34.xxx/") \+ else RULE34XXX_DETAIL_HTML+ return HttpResponse(200, {}, body)++ result = Rule34XxxConnector(+ transport=transport, max_items=1,+ credential=Credential("rule34xxx", {"user_id": "42", "api_key": "sekret"}),+ ).fetch("lazyprocrastinator")+ types = result.candidates[0].extra["tag_types"]+ self.assertEqual(types["3d"], "metadata")+ self.assertEqual(types["blender"], "metadata")+ self.assertEqual(types["3d_model"], "metadata")+ self.assertEqual(types["lazyprocrastinator"], "artist")+ self.assertEqual(types["reverse_cowgirl_position"], "general")+ self.assertNotIn("api_key", seen[1].url)+def test_missing_credential_fails_before_the_request(self):seen = []connector = Rule34XxxConnector(transport=_transport(record=seen))diff --git a/tests/test_follow_web.py b/tests/test_follow_web.pyindex d9c71be97..cca8b5c9f 100644--- a/tests/test_follow_web.py+++ b/tests/test_follow_web.py@@ -217,13 +217,18 @@ class FollowContractTests(unittest.TestCase):FollowCandidate(provider="rule34xxx", external_id="18534401",title="barnabas' mother · biting lip",url="https://rule34.xxx/index.php?page=post&s=view&id=18534401",- extra={"tags": "miqo'te y'shtola barnabas'_mother"}),+ extra={"tags": "miqo'te y'shtola barnabas'_mother",+ "tag_types": {"miqo'te": "general",+ "y'shtola": "general",+ "barnabas'_mother": "general"}}),), provider="rule34xxx", ref="final_fantasy")item = self._get()["groups"][0]["primary"]self.assertEqual(item["tags"], ["miqo'te", "y'shtola", "barnabas'_mother"])self.assertEqual(item["tag_types"],{"miqo'te": "general", "y'shtola": "general","barnabas'_mother": "general"})+ self.assertEqual(item["detail_tags"],+ ["miqo'te", "y'shtola", "barnabas'_mother"])self.assertEqual(item["title"], "barnabas' mother · biting lip")def test_external_file_pages_are_exposed_without_leaking_raw_media_urls(self):@@ -518,7 +523,8 @@ class FollowContractTests(unittest.TestCase):return FollowCandidate(provider="rule34video", external_id=external_id,title=f"Clip {external_id}",url=f"https://rule34video.com/video/{external_id}/x/",- extra={"tags": list(tags)})+ extra={"tags": list(tags),+ "tag_types": {tag: "general" for tag in tags}})def test_counts_follow_the_active_author_filter(self):"""筛掉一个作者,药丸上的数字必须跟着变。@@ -1685,6 +1691,7 @@ class FollowWebSourceTests(unittest.TestCase):self.assertPageContains(".fnote.followmedianote{margin:18px 0 8px}")self.assertPageContains("followAuthorAvatar(authorSources)")self.assertPageContains("followTagChip(item,tag,'button')")+ self.assertPageContains("item.detail_tags||item.tags||[]")self.assertPageContains(".followdetailtags .tg{max-width:none")self.assertPageContains("const postedBy=item.author&&foldName(item.author)!==foldName(author)")self.assertPageContains("openFollowDetail(id);")@@ -1754,6 +1761,7 @@ class FollowWebSourceTests(unittest.TestCase):"按行插入,避免把卡片那一行截断")# 列表还没渲染出来时(直达详情链接)仍回退到列表前self.assertPageContains("followList.before($('#stage'))")+ self.assertPageContains(".followlist>.stage{grid-column:1/-1;width:100%;min-width:0}")self.assertPageContains("scrollItemDetailIntoView();","滚到舞台本身而不是页面头部")self.assertPageContains("if(stage.parentElement!==main)main.insertBefore(stage,combo)")@@ -1863,17 +1871,26 @@ class FollowWebSourceTests(unittest.TestCase):tags = web_follow._item_tags(_Item({"tag": "lazyprocrastinator","tags": "lazyprocrastinator 1girls animated sound riding lazyprocrastinator",+ "tag_types": {"lazyprocrastinator": "artist", "1girls": "general",+ "animated": "metadata", "sound": "general", "riding": "general"},}))# 作者手柄本身不算标签:按作者筛已经有专门的筛选条,重复出现没有信息量。self.assertEqual(tags, ["riding"])video_tags = web_follow._item_tags(_Item({"tags": ["deep throat", "3D", "3d_animation", "breast squeeze"],"categories": ["2D", "Final Fantasy"],+ "tag_types": {"deep throat": "general", "3D": "metadata",+ "3d_animation": "metadata", "breast squeeze": "general",+ "2D": "metadata", "Final Fantasy": "copyright"},}))self.assertEqual(video_tags, ["deep throat", "breast squeeze"])screenshot_tags = web_follow._item_tags(_Item({"tags": "beach dead_or_alive 16:9 2026 female 1boy 1girls breasts "- "final_fantasy male ass pov blowjob",+ "final_fantasy male ass blender 3d 3d_model pov blowjob",+ "tag_types": {**{tag: "general" for tag in+ "beach 16:9 2026 female 1boy 1girls breasts male ass pov blowjob".split()},+ "dead_or_alive": "copyright", "final_fantasy": "copyright",+ "blender": "metadata", "3d": "metadata", "3d_model": "metadata"},}))self.assertEqual(screenshot_tags, ["pov", "blowjob"])typed = web_follow._item_tags(_Item({@@ -1886,11 +1903,20 @@ class FollowWebSourceTests(unittest.TestCase):self.assertEqual(web_follow._item_tags(_Item({"tags": " "})), [])# rule34.xxx 旧行存的是 HTML 转义形态;出口归一后与反转义的新写法# 是同一个身份,脏/净并存的重复项也合并成一个。- legacy = web_follow._item_tags(- _Item({"tags": "miqo'te y'shtola miqo'te"}))+ legacy = web_follow._item_tags(_Item({+ "tags": "miqo'te y'shtola miqo'te",+ "tag_types": {"miqo'te": "general", "y'shtola": "general"},+ }))self.assertEqual(legacy, ["miqo'te", "y'shtola"])+ # 旧行没有来源类型时不猜成 general;详情仍可显示全部原始标签。+ untyped = _Item({"tags": "blender reverse_cowgirl_position"})+ self.assertEqual(web_follow._item_tags(untyped), [])+ self.assertEqual(web_follow._item_all_tags(untyped),+ ["blender", "reverse_cowgirl_position"])# 热门帖能带上百个标签,整串发下去会把筛选条撑爆。- many = _Item({"tags": " ".join(f"t{n}" for n in range(200))})+ many_values = [f"t{n}" for n in range(200)]+ many = _Item({"tags": " ".join(many_values),+ "tag_types": {tag: "general" for tag in many_values}})self.assertEqual(len(web_follow._item_tags(many)), web_follow.MAX_ITEM_TAGS)def test_the_author_key_merges_one_person_across_sites(self):@@ -1930,6 +1956,12 @@ class FollowWebSourceTests(unittest.TestCase):# 名字为空时退回来源 id,不能让所有空名字挤成一组。self.assertNotEqual(key(label="", id=1), key(label="", id=2))+ def test_collection_is_container_copy_not_part_of_the_author_display_name(self):+ self.assertEqual(web_follow._author_display_text("Billyhhyb Collection"),+ "Billyhhyb")+ self.assertEqual(web_follow._author_display_text("Billyhhyb · patreon"),+ "Billyhhyb")+def test_avatars_only_come_from_providers_that_actually_serve_one(self):"""头像按 peach-reference-evidence:实测拿得到才给,取不到写「未取得」。@@ -2015,6 +2047,7 @@ 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(".replace(/\\s+collections?\\s*$/i,'').trim()")# 取不到图片时回退作者首字母;不能从来源标签切出中文“初”“一”。self.assertPageContains("function followAvatarInitial(group)")self.assertPageContains('title="没有可用头像"')diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex d24fc6676..993ce7a90 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -984,6 +984,8 @@ class WebUiSourceTests(unittest.TestCase):self.assertIn("Scroller", rules)self.assertIn("整页或大区块首次等待内容结构", rules)self.assertIn("同一次页面进入只呈现一段等待态", rules)+ self.assertIn("Skeleton 只覆盖真正等待的内容区", rules)+ self.assertIn("Skeleton 只保留给辅助技术的状态名", rules)self.assertIn("Empty State", rules)agents = (root / "AGENTS.md").read_text(encoding="utf-8")self.assertIn(".claude/skills/peach-web-ui/SKILL.md", agents)@@ -1288,7 +1290,7 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains("grid-template-columns:repeat(2,minmax(0,1fr))")self.assertPageContains("border-top:1px solid var(--line-soft);border-left:1px solid var(--line-soft);list-style:none")self.assertPageContains(".insighttable{border-top:0}")- self.assertPageContains(".insight-layout .managebar{margin-left:auto;margin-right:auto}")+ self.assertPageContains(".managebar{margin-left:auto;margin-right:auto}")self.assertPageContains(".insight-layout .managetitle,.insight-layout .pagelede{width:min(1100px,100%)")self.assertPageLacks(".tasteprivacy{margin:16px 16px 0")self.assertPageLacks('<p class="tasteprivacy">')@@ -1630,9 +1632,14 @@ class WebUiSourceTests(unittest.TestCase):def test_page_loading_uses_one_structural_skeleton_phase(self):self.assertPageContains("function renderCatalogLoading(label='正在读取作品')")self.assertPageContains("$('#grid').innerHTML=pageSkeletonHtml(label,{cards:true,className:'catalog-skeleton'})")+ self.assertPageContains("count.textContent='';count.setAttribute('aria-label',label)")+ self.assertPageContains(".grid>.skeletonpanel{grid-column:1/-1;width:100%;min-width:0}")self.assertPageContains("function renderInitialSurfaceLoading()")- self.assertPageContains("placeholder:`<div class=\"follow\">${pageSkeletonHtml('正在读取关注内容',{cards:true})}</div>`")- self.assertPageContains("showManagementBody({placeholder:pageSkeletonHtml('正在读取统计')})")+ self.assertPageContains("const followSkeletonHtml=(label='正在读取关注内容')")+ self.assertPageContains('<div class="followhead"><h2 class="pagetitle">关注</h2></div>')+ self.assertPageContains("placeholder:followSkeletonHtml('正在读取关注内容')")+ self.assertPageContains("pageSkeletonHtml('正在读取统计',{variant:'dashboard'})")+ self.assertPageContains(".skeletondashhero{min-height:330px;grid-template-columns:minmax(260px,36%) minmax(0,1fr)}")self.assertPageContains("showIndexLoading(people?'正在读取作者':'正在读取标签')")self.assertPageContains("$('#loadSentinel').innerHTML=loadingDotsHtml('继续载入中…')")self.assertPageContains("pageSkeletonHtml('正在读取推荐',{cards:true,className:'related-skeleton'})")diff --git a/web/app.css b/web/app.cssindex ffaa468ce..100e861ed 100644--- a/web/app.css+++ b/web/app.css@@ -468,7 +468,7 @@ body.photolight-open{overflow:hidden}.fcollapse{overflow:hidden;transition:height .2s ease-in-out}/* Geist Skeleton:整页/大区块等待内容结构时先占住稳定区域。 */-.skeletonpanel{min-height:240px;padding:16px}+.skeletonpanel{min-height:240px;padding:0}.skeletonpanel>div{display:grid;gap:12px}.skeleton{display:block;height:18px;border-radius:6px;background:var(--hover);animation:skeleton-pulse 1.4s ease-in-out infinite}@@ -477,6 +477,18 @@ body.photolight-open{overflow:hidden}.skeletoncard i,.skeletoncard b,.skeletoncard em{display:block;border-radius:6px;background:var(--hover);animation:skeleton-pulse 1.4s ease-in-out infinite}.skeletoncard i{aspect-ratio:16/9}.skeletoncard b{width:72%;height:18px}.skeletoncard em{width:46%;height:14px}+.grid>.skeletonpanel{grid-column:1/-1;width:100%;min-width:0}+.skeleton-dashboard>div{gap:16px}+.skeletondashhero,.skeletondashpanel{display:grid;min-width:0;overflow:hidden;border:1px solid var(--line-soft);+ border-radius:12px;background:var(--surface)}+.skeletondashhero{min-height:330px;grid-template-columns:minmax(260px,36%) minmax(0,1fr)}+.skeletondashhero i,.skeletondashhero b,.skeletondashpanel i,.skeletondashpanel b,.skeletondashpanel em{+ display:block;background:var(--hover);animation:skeleton-pulse 1.4s ease-in-out infinite}+.skeletondashhero i{margin:28px 24px;border-radius:7px}.skeletondashhero b{margin:24px;border-radius:7px}+.skeletondashpanel{grid-template-columns:1fr 1fr;gap:12px;padding:16px}+.skeletondashpanel i{grid-column:1/-1;width:26%;height:18px;border-radius:6px}+.skeletondashpanel b,.skeletondashpanel em{height:84px;border-radius:7px}+@media(max-width:640px){.skeletondashhero{grid-template-columns:minmax(0,1fr)}.skeletondashhero i{min-height:180px}.skeletondashhero b{min-height:220px}.skeletondashpanel{grid-template-columns:1fr}}@keyframes skeleton-pulse{0%,100%{opacity:.55}50%{opacity:1}}/* 缩放滑杆:原生 accent-color 的轨道太粗,自绘成与时长双滑块同一套 4px 细轨。底色是视频上的白色,所以这一套固定用白色而不是主题色。 */@@ -661,7 +673,7 @@ main{position:relative;z-index:1;padding:14px 16px 90px}stroke-linecap:round;stroke-linejoin:round}.managebar button:hover{background:var(--hover);color:var(--ink)}.managebar button[aria-pressed="true"]{background:var(--tungsten-soft);color:var(--tungsten);font-weight:600}-.insight-layout .managebar{margin-left:auto;margin-right:auto}+.managebar{margin-left:auto;margin-right:auto}.insight-layout .managetitle,.insight-layout .pagelede{width:min(1100px,100%);margin-left:auto;margin-right:auto}.count{position:sticky;top:calc(var(--topH) + var(--filterH));z-index:60;min-height:var(--sortH);color:var(--ink-2);margin:0 -16px 16px;padding:8px 16px;@@ -944,6 +956,7 @@ body[data-density="dense"] .card .meta .watchcount{display:none}.stage:not(.ambient-on){background:color-mix(in srgb,var(--surface) 88%,transparent)}.stage[hidden]{display:none}.grid>.stage{grid-column:1/-1;width:100%;min-width:0}+.followlist>.stage{grid-column:1/-1;width:100%;min-width:0}body.entity-open #tiers,body.entity-open #tagbar,body.index-open #tiers,body.index-open #tagbar{display:none}.sgrid{display:grid;grid-template-columns:minmax(0,1fr) minmax(350px,390px)}@@ -1796,6 +1809,7 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位.followitem .r34-character,.followdetailtags .r34-character,.followfilters .r34-character{--r34-tag:#68C76F}.followitem .r34-copyright,.followdetailtags .r34-copyright,.followfilters .r34-copyright{--r34-tag:#D675D6}.followitem .r34-metadata,.followdetailtags .r34-metadata,.followfilters .r34-metadata{--r34-tag:#F5A24A}+.followdetailtags .r34-unknown{--r34-tag:var(--muted)}.followitem .meta .s{min-height:21px}.fbadges{display:flex;flex-wrap:nowrap;gap:5px;min-width:0;overflow:hidden}.fbadge{padding:2px 8px;border:1px solid var(--border-15);border-radius:var(--badge-radius);font-size:var(--fs-xs);color:var(--ink-2)}.fbadge.wip{border-color:var(--meter);color:var(--meter)}diff --git a/web/app.js b/web/app.jsindex 7e083a6ba..d274ef4cd 100644--- a/web/app.js+++ b/web/app.js@@ -7,14 +7,17 @@ import {initMiddleTruncate(document);-const pageSkeletonHtml=(label,{cards=false,className=''}={})=>- skeletonHtml(label,{variant:cards?'cards':'panel',className});+const pageSkeletonHtml=(label,{cards=false,className='',variant=''}={})=>+ skeletonHtml(label,{variant:variant||(cards?'cards':'panel'),className});+const followSkeletonHtml=(label='正在读取关注内容')=>`<div class="follow">+ <div class="followhead"><h2 class="pagetitle">关注</h2></div>+ ${pageSkeletonHtml(label,{cards:true,className:'follow-content-skeleton'})}</div>`;$('#loadSentinel').innerHTML=loadingDotsHtml('继续载入中…');$('#tokLoader').insertAdjacentHTML('afterbegin',spinnerHtml('媒体加载中'));function renderCatalogLoading(label='正在读取作品'){const count=$('#count');count.setAttribute('aria-busy','true');- count.textContent=label;+ count.textContent='';count.setAttribute('aria-label',label);$('#grid').innerHTML=pageSkeletonHtml(label,{cards:true,className:'catalog-skeleton'});}/* 深链启动前先占住目标表面。后续路由仍画同一种 Skeleton,因此不会先出现首页@@ -25,7 +28,9 @@ function renderInitialSurfaceLoading(){'/playlists','/resource-sync','/follow','/follow-manage']);if(management.has(path)||path.startsWith('/follow/item/')){const stats=$('#stats');stats.hidden=false;$('#grid').innerHTML='';- stats.innerHTML=pageSkeletonHtml('正在读取页面',{cards:path.startsWith('/follow')});+ stats.innerHTML=path.startsWith('/follow')+ ?followSkeletonHtml('正在读取关注内容')+ :pageSkeletonHtml('正在读取页面');return;}if(path==='/performers'||path==='/creators'||path==='/tags'||@@ -1630,7 +1635,8 @@ async function openStats(push=true,focusResource=false){const surface=claimSurface('/stats');enterManagementSurface();disposeStage(false);- showManagementBody({placeholder:pageSkeletonHtml('正在读取统计')});+ showManagementBody({placeholder:`<div class="insightpage">${+ pageSkeletonHtml('正在读取统计',{variant:'dashboard'})}</div>`});const d=await api('/api/stats');if(!surfaceCurrent(surface))return;showManagementBody();@@ -2399,7 +2405,7 @@ function followWhen(item){return text;}-const followTagType=(item,tag)=>item.tag_types&&item.tag_types[tag]||'general';+const followTagType=(item,tag)=>item.tag_types&&item.tag_types[tag]||'unknown';/* 卡片、详情、筛选条和在线标签页都只消费服务端的内容标签投影。过滤只维护一份,原始来源标签仍完整留在 metadata。 */const followCardTags=item=>item.tags||[];@@ -2575,7 +2581,9 @@ async function openFollowDetail(id,push=true,mediaIndex=null,preserveReturn=fals<button class="followimagearrow next" data-follow-image-step="1" aria-label="下一张图片" title="下一张">${icon('chevron-right')}</button><div class="followimagedots" role="group" aria-label="${imageMedia.length} 张图片">${imageMedia.map((image,index)=>`<button data-follow-image-item="${image.index}" aria-current="${index===imagePosition}" aria-label="第 ${index+1} 张,共 ${imageMedia.length} 张" title="第 ${index+1} 张"></button>`).join('')}</div>`:'';const badges=followBadges({primary:item,variants:[],duplicates:[],has_wip:item.variant_kind==='wip'});- const tags=(item.tags||[]).map(tag=>followTagChip(item,tag,'button')).join('');+ // 卡片只消费 general 内容投影;详情保留来源记录的全部类型,并按类型着色。+ const tags=(item.detail_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:'';/* 舞台就近展开:插在被点击那张卡片所在的一行之后,而不是整个列表之前。@@ -3016,7 +3024,7 @@ async function openFollow(push=true,renderForDetail=false){if(location.pathname==='/follow')readFollowView();const surface=claimSurface(renderForDetail?surfacePath():'/follow');showManagementBody({manage:false,- placeholder:`<div class="follow">${pageSkeletonHtml('正在读取关注内容',{cards:true})}</div>`});+ placeholder:followSkeletonHtml('正在读取关注内容')});const [data,credentials]=await Promise.all([api(followPageUrl(0)),api('/api/follow/credentials').catch(()=>({providers:[]})),@@ -3105,20 +3113,22 @@ function followAuthorAvatar(group){更像作者自己写的名字。 */function followAuthorName(group){if(!group.length)return '';+ const clean=value=>String(value||'')+ .replace(/\s*[·|]\s*[A-Za-z0-9_-]+\s*$/,'')+ .replace(/\s+collections?\s*$/i,'').trim();const entity=group.find(source=>source.entity_name);if(entity)return entity.entity_name;const aliasGroup=(followData.author_aliases||[]).find(item=>`name:${item.canonical_key}`===group[0]?.author_key);- if(aliasGroup)return aliasGroup.canonical_name;+ if(aliasGroup)return clean(aliasGroup.canonical_name);// 官方主页来源不只优先提供头像,也优先提供作者写法;否则 F95 的线程标题// `Lazy Procrastinator Collection` 会因为大写字母更多而抢成分组标题。const official=group.find(source=>source.official_avatar_url);if(official){- const officialName=String(official.label||'')- .replace(/\s*[·|]\s*[A-Za-z0-9_-]+\s*$/,'').trim();+ const officialName=clean(official.label);if(officialName)return officialName;}- const names=group.map(source=>String(source.label||'').replace(/\s*[·|]\s*[A-Za-z0-9_-]+\s*$/,''))+ const names=group.map(source=>clean(source.label)).filter(Boolean);if(!names.length)return group[0].label||group[0].ref||'';const caps=text=>(text.match(/[A-Z]/g)||[]).length;diff --git a/web/js/ui-components.js b/web/js/ui-components.jsindex 60076f8a5..72988c66f 100644--- a/web/js/ui-components.js+++ b/web/js/ui-components.js@@ -37,9 +37,13 @@ export function loadingDotsHtml(label='正在处理', {className=''}={}){/** Geist Skeleton: reserve a large content region while its structure is loading. */export function skeletonHtml(label='正在读取内容',{className='',variant='panel'}={}){- const kind=new Set(['panel','cards']).has(variant)?variant:'panel';+ const kind=new Set(['panel','cards','dashboard']).has(variant)?variant:'panel';const body=kind==='cards'?Array.from({length:6},()=>`<span class="skeletoncard"><i></i><b></b><em></em></span>`).join('')+ :kind==='dashboard'+ ?`<span class="skeletondashhero"><i></i><b></b></span>+ <span class="skeletondashpanel"><i></i><b></b><em></em></span>+ <span class="skeletondashpanel"><i></i><b></b><em></em></span>`:`<span class="skeleton" style="width:38%"></span><span class="skeleton" style="width:100%"></span><span class="skeleton" style="width:100%"></span>