Peach: Local-first video metadata scraper and media manager.
feat(web): 数据管理只放一段骨架,卡片补分项,操作条按 Geist 窄屏做法收敛
longmeidao9913aff599c0
diff --git a/docs/STATUS.md b/docs/STATUS.mdindex 63aaa7370..a5a2e92a1 100644--- a/docs/STATUS.md+++ b/docs/STATUS.md@@ -19,6 +19,7 @@## 已核验能力+- 2026-09-02 数据管理页:一次刷新只放一段骨架,每张卡多给一行分项,操作条按 Geist 的窄屏做法收敛。**两段动画**的根因是加载态写了两份——深链启动时 `renderInitialSurfaceLoading` 铺一张通用大布局骨架,路由到位后各页再铺自己那张(数据管理那张还是 Loading Dots)。现在 `MANAGEMENT_PLACEHOLDERS` 是唯一定义,两处都从这里取;`skeletonHtml` 给每张骨架盖一个 `data-skeleton` 身份键,`showManagementBody` 认出屏幕上已经是同一张就不再重画——`innerHTML` 换新节点会把 shimmer 从头放一遍,用户看到的就是同一段动画闪两次。浏览器实测:把开机那张骨架摆回 `#stats` 再走一次路由,新建骨架节点 0 个。顺带修好 `/follow-manage` 深链启动时误用关注骨架。**卡片内容**:垃圾文件按类型分项、回收站补占用体积、复核列前三类,数字全部来自同一份 payload,不为第二行多发请求;`q_items` 把条数和体积放进同一次聚合(新增 `bytes`)。重复文件为 0 时写「没有重复内容」而不是 0 组。三个「· 在线」徽章换成一行来源名——卡片要说的是这次扫哪几个来源。**高度**:删掉 `.cleanupfieldset{min-height:176px}`,那条地板是三列时用来对齐同一行的,单列下只是留白;现在无分项的卡 153px,和「网盘与账本」一致,有分项的 174px。**窄屏操作条**按 375px 实测的 Geist 行为重做(证据登记在 `vercel-geist-fieldset-scroller-empty-state` 的 2026-09-02 追加块):Geist 在 375px 下操作条仍是一行 `row`/`nowrap`,`min-height:56px` 按说明行数长到 65/85/105px,12 颗按钮宽 70–186px 没有一颗铺满。我们此前 640px 以下把条子竖过来、按钮 `width:100%`,那是自己加的;改成固定高度换 `min-height` + 上下 8px,说明 `min-width:0` 可换行、按钮 `flex:none` 不被压。**按钮底色**按用户指定统一填 `--surface`:条子是 `--overlay-5`,更深的底才分得出来,此前数据管理六颗透明底与同页 `.resourceaction` 是两种按钮。Windows 正式全量 1690 项通过、13 项按平台跳过;渲染在隔离预览实例(127.0.0.1:8900,账本副本、只读)按 420px 与桌面宽两档核对。本轮只改静态 JS/CSS/HTML 与一个只读查询,未新增依赖,未写真实 ledger、候选或媒体,未重启或替换生产入口。- 2026-09-02 关注页四处「同一件事两套口径」一并收口,在线资产就地播放,人脸检出换成 YuNet。**角标与队列**:paheal 一组 9 条里有 1 张图,卡上写「9 个版本」、播放角标写「8 个视频」,点开也是 8 条;`2B Camp [4K]` 更极端——卡上写「2 个版本」,同组另一条不是可播视频,`collection` 因此整个为 null,点开只有 1 条。两处改为共用 `followOpenableItems(group)`,`count > 1` 才出角标。**WIP 贴错条目**:`has_wip` 是组属性(`any(... for item in self.variants)`),角标却挂在主条目标题旁边,`2B Camp [4K]` 判的是 alt 却被读成半成品;现在这一条本身是 WIP 才写 `WIP`,同组有则写「含 WIP」。**`[1080]` 与 `[4K]` 分不到一组**:`_ALT_MARKERS` 只认 `(\d{3,4})p`,括号里写的是不带 `p` 的裸数字,于是 `2b camp 1080` 和 `2b camp` 是两个键;补了已知分辨率档位白名单,`Sayuri - Cowgirl 2`、`Scene [2023]`、`Part [1200]` 都不受影响。**paheal 上传时间被抹**:每个候选都要单独打一次详情页,被限流时 `_detail` 返回 {},而 upsert 无条件覆盖,把上一轮取到的时间和时长写成 NULL,`COALESCE(published_at, first_seen_at)` 于是让界面显示抓取时刻——实测 168 条里 7 条如此;详情页加退避重试,upsert 改成 `COALESCE(excluded, 现有)`。**在线资产**此前在馆藏详情里只给一道闸;`path` 是来源作品页不假,但能播的代理一直都在(`/follow-stream?id=<follow_item>`),保存时写的就是 `follow_item.asset_id`,`/api/item` 反查回传 `follow_item_id`,播放器直接用,反查不到才拦。同时补上一直没有的「下载到本地」:关注详情一个 `<a download>` 走 `download=1`,服务端按条目标题生成文件名(RFC 5987,中日文落得下来),不回传上游地址。**人脸检出**:`pyproject.toml` 钉的是 `opencv-python-headless==5.0.0.93`,而 OpenCV 5 把 Haar 级联移出了 Python wheel(`cv2.CascadeClassifier` 不存在、`cv2/data/` 只剩 `__init__.py`),两个取景脚本一直抛 AttributeError,954 张封面 0 个 sidecar——「人脸取景没生效」的成因在这里,不在取景公式上,`docs/REUSE.md` 那条也一直和实际装的版本对不上。新增 `peach.face_detect` 两脚本共用,改用同属 OpenCV 的 `cv2.FaceDetectorYN`(YuNet 不是 OpenCV 的替代品,换的只是检出器这一层),模型按固定 URL 取一次并校验 sha256(`8f2383e4…52fa4`,232,589 字节)落 `peach-data/tools/yunet/`、不进 Git,校验不过的文件直接删掉。实测 12 张封面检出 11(Haar 是 46 张检出 24、512 张头像检出 313),`259LUXU-1490` 检出 `cx=0.813` 即两栏封套右侧那个人,`ABW-232` 检出 10 张脸、按面积最大的正落在右侧正封;sidecar 已写 `cx`,契约层 `cover_frame` 目前仍只下发 `cy`,横向取景留作下一步。Windows 正式全量:关注批 1658 项、YuNet 批 1664 项,均 13 项按平台跳过。**rule34.xxx 标签类型回填进行中**:2153 条里已补到 241 条,可反复运行、随时接着跑。三轮实测钉出频率口径——0.35 秒间隔 400 条只取到 28 条,1.1 秒 120 条取到 51 条,加上详情页退避重试后 100 条取到 89 条;那 372 条「帖子页没有解析出类型」是假的,事后逐条直取全部 200 且 `#tag-sidebar` 正常,也就是「被限流」和「确实没有类型」在数据里长得一模一样,现已在连接器里退避重试三次、仍取不到才留空交给下一轮。回填脚本的备份一并从 `shutil.copy2` 换成 SQLite 备份 API:账本是 WAL 模式,已提交但未 checkpoint 的事务在 `-wal` 里,只复制主库会得到一份少了最近改动、看起来却完全正常的账本。本轮未替换生产入口,未删除媒体,`follow_item` 条数前后一致(3582 → 3582)。- 2026-09-02 管理区归并到「数据管理」,界面口径说明整批清退,三处交互缺陷已修。人工复核、回收站、高清版和垃圾文件、重复文件、空文件夹是同一件事的不同步骤,此前散在管理菜单里各占一行;统计页还挂着链接管理与资源同步两块面板——它们改的是账本和外部现实的对齐,跟「库里现在有多少」不是一件事。现在都归到数据管理一页(原「数据清理」,路由 `/data-cleanup` 不变),管理菜单只留统计/口味/数据管理/关注;`MANAGE_SECTIONS` 仍是全量身份注册表,直达 URL 和「钉到顶层侧栏」都不受影响。新增 `/api/review?counts=1` 只回计数:卡片要的是一个数字,完整 payload 带着每条候选全文是兆级。**文案判据**(已写回 `peach-web-ui`):界面不解释数字是怎么算出来的,口径、免责、隐私声明、「不会做什么」「按什么汇总」一律删,单位跟着数字走(`待同步 497 项`);上一轮跑完的扫描结果不常态显示——那是那一刻的快照,而页面上没有任何东西说它是旧的,因此只有仍在跑的扫描才自动接管页面。**框体**按用户指出的 Geist 规范重做了两轮:第一版给标题加了独立横条和下边框,实际 `vercel.com/geist/fieldset` 的 Multiple Fieldsets 示例全框只有一条线(在底部操作条上方),标题是正文区第一行;现为 `fieldsetTitle()` + `--fieldset-bar-h:52px` 的操作条,按钮一律靠右,左侧有说明时说明推到最左。原生 `<legend>` 不再使用:它在上边框上开缺口,同组卡片内容高度不同时缺口位置也跟着不齐。链接统计不再挤成一行——`官网 · 事务所` 里的间隔点和拼接用的间隔点撞在一起,读出来是「社媒 373 · 官网 · 事务所 224」,分不清哪个数字属于哪一类;类型名改成 `官网/事务所`,每类各占一格,「最多的站点」单独一行。**三个缺陷**:直接打开 `/parts/28125/28125` 再关闭播放器,首页永远停在加载骨架上——判据原先是「`#grid` 有没有子节点」,而深链启动时网格里正躺着那张骨架,它也是子节点;卡片一定带 `data-id`,骨架没有(浏览器实测复现并验证)。撤销原先是「关掉回执 + 另发一条已撤销」,底部对齐的栈里一进一出会整块跳一格,改成结果写回同一条 toast,退场也先把高度写死再过渡到 0。设置面板给 body 加 `overflow:hidden`,滚动条一消失整页横向跳一次,`html` 预留 `scrollbar-gutter:stable`(实测位移 0)。**关注详情标签**按 rule34.xxx 自己的分类顺序分组:2026-09-01 实测帖子页 `18622796`/`18622794`,`#tag-sidebar` 的 `li.tag-type-*` 出现顺序均为 copyright → character → artist → general → metadata,组内按名升序,缺的类型跳过不占位,证据与哈希已登记进 `rule34-follow-tags-and-collections`。**合并分卷与版本**成为设置项(浏览组,默认开);折叠逻辑本来就在,缺的只是开关,实测关掉后首页卡片 77 → 78。Windows 正式全量通过、13 项按平台跳过;数据管理、统计与设置面板在隔离预览实例(127.0.0.1:8900,账本副本、只读)核对渲染。本轮只改静态 JS/CSS/HTML 与一个只读 API 分支,未新增依赖,未写真实 ledger、候选或媒体,未重启或替换生产入口。- 2026-09-01 `/api/related` 从 6.2 秒降到 0.48 秒:`rank_related` 的 MMR 每选中一条,就把整个候选池和**全部**已选重算一遍 closeness,代价是 O(limit² × 池);候选池上限 4000,生产实测 limit=20 要 3.4 秒、28 要 6.3 秒、60 要 32.8 秒,而单张 poster 只要 4.8 毫秒——耗时几乎全在排序,不在 SQL。「候选对已选集的最大 closeness」改为增量维护(新选中一条时只和这一条比一次、取较大值),并把 `_sets` 的重复构造提到循环外;代价降到 O(limit × 池),同一台机器对比 limit=28 为 6.29 → 0.48 秒、limit=60 为 32.75 → 1.10 秒。这是等价变换,不是调参:同一账本上 6 个 seed(2413/485/31025/22887/86187,limit 8/20/28)的 `/api/related` 响应新旧**逐字节相同**;朴素实现作为基准留在 `tests/test_related.py`,等价性对 limit 0/1/3/8/25/200 × diversity 0/0.22/0.6 全部成立,另加一条线性代价上界,任何「每轮重算全部已选」的写法会当场超出。详情页「接着看」、点开 Mix 和悬浮翻动共用这条路径,一起受益。Mix 悬浮翻动跟着从 5 张提到 9 张,第一张改为面板建好后 420 毫秒就翻、不再干等一个完整间隔:实测鼠标停下到第一次翻动 942 毫秒(上一版 1801 毫秒,旧 related 下为 3.1–7.6 秒),9 张面板全部解码成功,中途离开能把预热定时器一并收掉,1440 视口横向溢出 0。变基后工作树 Windows 正式全量 1640 项通过、13 项按平台跳过。本轮未写真实 ledger、候选或媒体,也未新增接口、依赖或迁移。diff --git a/docs/reference-snapshots/vercel-geist-fieldset-scroller-empty-state.md b/docs/reference-snapshots/vercel-geist-fieldset-scroller-empty-state.mdindex 8f71107ba..0eeff147b 100644--- a/docs/reference-snapshots/vercel-geist-fieldset-scroller-empty-state.md+++ b/docs/reference-snapshots/vercel-geist-fieldset-scroller-empty-state.md@@ -21,3 +21,27 @@- 人工复核卡统一为 440px 高,正文 20px 内边距并纵向滚动,Footer 最小 56px;大量预览不再另套第二个滚动区。- 回收站、普通零结果、重复文件、复核、高清版、播放列表与关注页空态统一包含标题和说明;页面工具条与空态之间统一为 16px。- 异步页面使用导航代际 token;即使快速离开又返回相同路径,旧请求也不能覆盖新页面。++## 2026-09-02 追加:窄屏下的 Fieldset 操作条(浏览器计算样式实测)++在 <https://vercel.com/geist/fieldset> 上把视口设为 375×812,读页面上 12 颗 footer 按钮的+`getBoundingClientRect` 与 `getComputedStyle`。React 渲染的页面没有可哈希的上游产物,+证据是这次的实测读数本身,口径同 `vercel-geist-controls-measured.md`。++- 操作条在 375px 下仍是 `display:flex`、`flex-direction:row`、`flex-wrap:nowrap`、`align-items:center`;+ 没有任何断点把它竖起来。+- 高度是 `min-height:56px` 而不是固定高:说明换行时实测长到 65px(一行)、85px(两行)、105px(三行)。+- 内边距 `12px 12px 12px 20px`——右边比左边窄,按钮那侧收紧。+- 按钮一律保持内容宽度:`Accept` 71px、`Update` 71px、`Save Changes` 118px、+ `Change Password` 142px、`Verify API Connection` 166px、`Update Payment Method` 186px,+ 条宽 277px,**没有一颗铺满**。按钮靠 `margin-left:auto` 推到最右,说明占左侧剩余宽度并换行。++## Peach 适配(2026-09-02)++- 数据管理与资源同步的操作条由固定 `height:52px` 改为 `min-height:52px` + 上下 8px 内边距,+ 说明行数变多时长高而不是溢出。+- 删掉 640px 以下把操作条改成 `flex-direction:column`、按钮 `width:100%` 的那一段——+ 它是我们自己加的,Geist 在 375px 下并没有这个断点。说明加 `min-width:0` 允许被压窄换行,+ 按钮加 `flex:none` 不参与压缩。+- 操作条按钮统一填 `--surface`:条子本身是 `--overlay-5`,更深的底才让按钮从条子上分出来。+ 此前数据管理那六颗是透明底,和同一页「网盘与账本」的 `.resourceaction` 并排时是两种按钮。diff --git a/docs/reference-sources.json b/docs/reference-sources.jsonindex 57b778074..ec908d1b4 100644--- a/docs/reference-sources.json+++ b/docs/reference-sources.json@@ -156,8 +156,8 @@"name": "Vercel Geist Fieldset、Scroller 与 Empty State","url": "https://vercel.com/geist/fieldset","snapshot": "docs/reference-snapshots/vercel-geist-fieldset-scroller-empty-state.md",- "checked_on": "2026-08-30",- "sha256": "482b4ccf1fcf09bc9f7dd5824f5368f71e8eb8804de5709a19ea6cc32d990df5",+ "checked_on": "2026-09-02",+ "sha256": "536c57cb8f014881a677329c4898e7b3ad9d47b257a108786ad4590a3ce0f65f","role": "人工复核 Fieldset、固定高度 Scroller、Empty State 结构与快速导航请求隔离的项目级依据。","consumers": ["web/js/ui-components.js",diff --git a/src/peach/web_contract.py b/src/peach/web_contract.pyindex 3360ee7c4..7b76370b0 100644--- a/src/peach/web_contract.py+++ b/src/peach/web_contract.py@@ -482,8 +482,12 @@ def q_items(contract: WebContract, args):rows = [dict(r) for r in c.execute(sql, par + [fetch_limit, off])]has_more = len(rows) > lim if not include_total else Nonerows = rows[:lim]- cnt = (c.execute("SELECT count(*) FROM asset a WHERE " + " AND ".join(where), par).fetchone()[0]- if include_total else None)+ # 条数和体积同一次聚合出来:回收站卡片要说的是「清空能腾出多少」,+ # 为它单独再发一次请求只是把同一条 WHERE 又跑一遍。+ cnt, total_bytes = (+ c.execute("SELECT count(*),COALESCE(sum(a.size),0) FROM asset a WHERE "+ + " AND ".join(where), par).fetchone()+ if include_total else (None, None))# 卡片要显示出镜者和高权重标签,不能只有番号 —— 一次批量取,别 N+1if rows:ids = [r["id"] for r in rows]@@ -534,7 +538,7 @@ def q_items(contract: WebContract, args):r.pop("path", None) # 路径不外发,串流走 idattach_multipart_groups(contract, rows)attach_edition_groups(contract, rows)- return {"total": cnt, "items": rows, "has_more": has_more}+ return {"total": cnt, "bytes": total_bytes, "items": rows, "has_more": has_more}def con_tags(contract: WebContract, ids, qm):with contract.read_connection() as c:diff --git a/tests/test_rm_web.py b/tests/test_rm_web.pyindex 45e3de341..52d9aa622 100644--- a/tests/test_rm_web.py+++ b/tests/test_rm_web.py@@ -386,9 +386,27 @@ class WebDataTests(unittest.TestCase):self.contract, {"limit": "1", "offset": "0", "count": "0"},)self.assertIsNone(result["total"])+ self.assertIsNone(result["bytes"], "不算总数时也别去扫体积")self.assertEqual(len(result["items"]), 1)self.assertTrue(result["has_more"])+ def test_item_totals_carry_occupied_bytes_for_the_trash_card(self):+ """回收站卡片要说的是「清空能腾出多少」,体积跟条数同一次聚合出来。++ 为它单独发一次请求只是把同一条 WHERE 再跑一遍;口径也必须跟着筛选走,+ 不能变成整库体积。+ """+ con = sqlite3.connect(self.db_path)+ con.execute("UPDATE asset SET disposal='trash' WHERE id IN (2,3)")+ con.commit()+ con.close()+ trash = rm_web.q_items(self.contract, {"state": "trash", "limit": "10"})+ self.assertEqual(trash["total"], 2)+ self.assertEqual(trash["bytes"], 210, "回收站里是 200 和 10 两条")+ live = rm_web.q_items(self.contract, {"limit": "10"})+ self.assertEqual(live["total"], 1)+ self.assertEqual(live["bytes"], 100, "体积口径必须跟着同一条筛选走")+def test_legacy_length_tags_are_hidden_in_favor_of_numeric_minutes(self):con = sqlite3.connect(self.db_path)con.execute(diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex b61729d99..d05f7442e 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -1987,6 +1987,34 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageLacks("detailpending")self.assertPageLacks("showItemDetailLoading(origin,above)")+ def test_every_management_surface_paints_the_same_skeleton_on_boot_and_on_route(self):+ """整页刷新只能出现一段加载动画,不是先大布局骨架、再各页自己的加载态。++ 深链启动和路由到位后各写各的占位时,`/data-cleanup` 刷新会先闪一张通用+ 骨架、再换成 Loading Dots。占位只留一份定义、两处都从这里取;骨架带+ `data-skeleton` 身份,showManagementBody 认出屏幕上已经是同一张就不重画+ ——重画会换掉节点,shimmer 从头再放一遍,看上去就是同一段动画闪两次。+ """+ self.assertPageContains("const MANAGEMENT_PLACEHOLDERS={")+ self.assertPageContains("const managementPlaceholder=path=>")+ for path in ("'/stats'", "'/taste'", "'/data-cleanup'", "'/duplicates'",+ "'/review'", "'/quality-goals'", "'/playlists'", "'/follow-manage'"):+ self.assertPageContains(f" {path}:()=>", "占位没有收进唯一那份定义")+ self.assertPageContains(f"managementPlaceholder({path})", "路由没有取那份定义")+ # /resource-sync 只是数据管理页的锚点,启动占位得是数据管理那张。+ self.assertPageContains("'/resource-sync':()=>MANAGEMENT_PLACEHOLDERS['/data-cleanup']()")+ self.assertPageContains("stats.innerHTML=path.startsWith('/follow')&&path!=='/follow-manage'")+ self.assertPageContains('''data-skeleton="${esc(kind)}${className?`/${esc(className)}`:''}"''')+ self.assertPageContains(+ "const painted=$('#stats').querySelector('[data-skeleton]')?.dataset.skeleton||''")+ self.assertPageContains("if(!next||next!==painted)$('#stats').innerHTML=placeholder")+ # 数据管理曾经是这一条:骨架之后再盖一层 Loading Dots,那就是第二段动画。+ self.assertPageLacks("loadingDotsHtml('正在读取数据管理状态…')")+ self.assertPageLacks(".cleanuploading")+ # 数据管理是一列 fieldset,骨架不能是三列海报网格。+ self.assertPageContains(".cleanup-skeleton>div{grid-template-columns:minmax(0,1fr);gap:16px}")+ self.assertPageContains(".cleanup-skeleton .skeletoncard em{width:100%;height:var(--fieldset-bar-h)")+def test_loading_actions_are_inert_and_dimmed_without_losing_focus(self):"""用户触发的等待态统一走 Geist loading button,而不是各页自造半套状态。"""self.assertPageContains("control.setAttribute('aria-busy','true')")@@ -2403,12 +2431,73 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains(".geist-fieldset-title{margin:0 0 10px;")self.assertPageLacks(".geist-fieldset-header")self.assertPageContains(".cleanupfieldset>.geist-fieldset-footer{box-sizing:border-box;"- "height:var(--fieldset-bar-h);")+ "min-height:var(--fieldset-bar-h);")# 按钮一律靠右;左边有说明时说明推到最左。self.assertPageContains("justify-content:flex-end;gap:8px;")- self.assertPageContains(".resourcesyncfooter>p,.resourceapplyrow>p{margin-right:auto}")+ self.assertPageContains(".resourcesyncfooter>p,.resourceapplyrow>p{min-width:0;margin-right:auto}")self.assertPageContains("if(path==='/data-cleanup'){await openDataCleanup(false);return}")+ def test_fieldset_bars_keep_one_row_and_one_button_shape_on_narrow_screens(self):+ """窄屏下操作条仍是一行,按钮按内容宽、填 --surface,不铺满也不换第二种样式。++ 证据:`docs/reference-snapshots/vercel-geist-fieldset-scroller-empty-state.md`+ 的 2026-09-02 追加块——375px 视口下 Geist 的 Fieldset footer 仍是+ `flex-direction:row`、`nowrap`,min-height 56px 按说明行数长到 65/85/105px,+ 12 颗按钮宽 70–186px,没有一颗铺满。原先 640px 以下把条子竖过来、按钮+ `width:100%`,那是我们自己加的,不是 Geist 的做法。++ 底色同理:条子是 `--overlay-5`,按钮填比它更深的 `--surface` 才分得出来。+ 数据管理那六颗此前是透明底,和同一页「网盘与账本」的 `.resourceaction`+ 并排时是两种按钮。+ """+ self.assertPageContains(".cleanupfieldset>.geist-fieldset-footer{box-sizing:border-box;"+ "min-height:var(--fieldset-bar-h);")+ self.assertPageContains("padding:8px 16px 8px 20px;")+ self.assertPageContains(".resourcesyncfooter,.resourceapplyrow{box-sizing:border-box;"+ "min-height:var(--fieldset-bar-h);")+ # 说明能被压窄并换行,按钮不参与压缩。+ self.assertPageContains(".resourcesyncfooter>p,.resourceapplyrow>p{min-width:0;margin-right:auto}")+ self.assertPageContains(".cleanupfieldset button{box-sizing:border-box;flex:none;min-height:32px;")+ self.assertPageContains("background:var(--surface);color:var(--ink-2);display:inline-flex;")+ self.assertPageContains(".cleanupfieldset button:hover{background:var(--hover);"+ "border-color:var(--ink-2);color:var(--ink)}")+ self.assertPageLacks(".resourcesyncfooter button{width:100%;justify-content:center}")+ self.assertPageLacks(".resourcesync .resourcesyncfooter{align-items:stretch;flex-direction:column}")+ self.assertPageLacks(".resourcesync .resourceapplyrow{align-items:stretch;flex-direction:column}")+ self.assertPageLacks(".resourcesync #resourceApply{width:100%}")++ def test_each_cleanup_card_shows_the_breakdown_already_in_its_payload(self):+ """每张卡在主数字下再给一行分项,用的是同一份 payload 里已有的数字。++ 卡片只有一个总数时,一列 fieldset 里剩下的全是空白;分项本来就在+ `/api/ads` 的 counts、`/api/duplicates` 的 reclaimable 和 `/api/review?counts=1`+ 里,不必为第二行多发请求。空的分项行整行不占位——没有分项的卡不该+ 比别人多留一段白。+ """+ cleanup = self.page.split("async function openDataCleanup(", 1)[1].split(+ "let dupData=null;", 1)[0]+ self.assertIn("JUNK_KIND_OPTIONS.filter(([key])=>key&&Number(junkCounts[key])>0)", cleanup,+ "垃圾文件没有按类型给分项")+ self.assertIn("已忽略 ${Number(junk.dismissed_total).toLocaleString()}", cleanup)+ self.assertIn("可回收 ${fmtSize(duplicates.reclaimable||0)}", cleanup)+ self.assertIn("'没有重复内容'", cleanup, "0 组时别写成「0 组 · 0 个文件」")+ self.assertIn('<p class="cleanupmeta" data-cleanup-meta="${section}">', cleanup)+ counts = self.page.split("async function paintDataManagementCounts()", 1)[1].split(+ "let dupData=null;", 1)[0]+ self.assertIn("REVIEW_LABELS[key]||key", counts, "人工复核的分项得是分类名")+ self.assertIn("`其余 ${rest.toLocaleString()}`", counts)+ self.assertIn("`占用 ${fmtSize(data.bytes||0)}`", counts, "回收站要说清空能腾出多少")+ self.assertPageContains(".cleanupmeta:empty{display:none}")+ # 三个「· 在线」徽章换成一行来源名:在线与否是资源同步那块的读数,+ # 在空文件夹卡上只有离线时才改变结论。+ self.assertPageLacks("class=\"cleanupsource\"")+ self.assertPageLacks(".cleanupsources{")+ self.assertIn("`${offline.map(sourceName).join(' · ')} 离线`", cleanup)+ self.assertIn("<strong>${online.length.toLocaleString()} 个来源可扫描</strong>", cleanup)+ # 单列布局里高度由内容决定,和同页「网盘与账本」一致;三列时的对齐地板+ # 到了单列只剩下把每张卡撑出一段空白。+ self.assertPageLacks("min-height:176px")+def test_duplicate_batch_keeps_one_per_cluster_not_one_per_code(self):# 每组各自选 keeper:合集与分卷已经在数据层拆成不同簇,界面不能再按番号合并。self.assertPageContains("function duplicateVictims(groups,keep)")@@ -3164,8 +3253,7 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains('class="resourcepanel"')self.assertPageContains('class="resourceapplyrow"')self.assertPageContains(".resourceaction{box-sizing:border-box;height:36px")- self.assertPageContains("@media(max-width:640px){.resourcesync .resourcesyncfooter{align-items:stretch;flex-direction:column")- self.assertPageContains(".resourcesync .resourcesources{grid-template-columns:1fr}")+ self.assertPageContains("@media(max-width:640px){.resourcesync .resourcesources{grid-template-columns:1fr}")self.assertPageContains(".resourcesyncbox,.resourcepanel{overflow:clip;border:1px solid var(--line-soft);border-radius:12px")self.assertPageContains(".resourcesources article+article{border-left:1px solid var(--line-soft)}")self.assertPageContains(".resourceapplyrow .resourcesyncok{color:var(--success)}")diff --git a/web/app.css b/web/app.cssindex 941a77493..4cb301e94 100644--- a/web/app.css+++ b/web/app.css@@ -251,7 +251,7 @@ button[aria-busy="true"],[role="button"][aria-busy="true"]{.reviewstate:empty{display:none}.reviewalias{margin:2px 0 0;font-size:var(--fs-xs);color:var(--muted)}.reviewactions button{box-sizing:border-box;height:32px;border:1px solid var(--border-15);border-radius:8px;background:transparent;color:var(--ink-2);padding:0 12px;font-size:var(--fs-sm);cursor:pointer}.reviewactions button:hover{border-color:var(--tungsten);color:var(--ink)}.reviewactions .approve{background:var(--tungsten);border-color:var(--tungsten);color:#fff;font-weight:600}.reviewactions .approve:hover{background:color-mix(in srgb,var(--tungsten) 82%,#000);color:#fff}.reviewactions .skip{color:var(--meter)}.reviewactions .skip:hover{background:var(--meter);border-color:var(--meter);color:#fff}.reviewactions .reject{color:var(--drop)}.reviewactions .reject:hover{background:var(--drop);border-color:var(--drop);color:#fff}-.cleanuploading,.junkloading{grid-column:1/-1;min-height:280px;display:grid;place-items:center}+.junkloading{grid-column:1/-1;min-height:280px;display:grid;place-items:center}/* 数据管理整页收进一条窄列(vercel.com/geist/fieldset 实测示例块宽 812px),fieldset 一行一个,不再拼三列。 */.cleanuppage{width:min(812px,100%);margin:0 auto}@@ -261,28 +261,38 @@ button[aria-busy="true"],[role="button"][aria-busy="true"]{操作条固定 52px、竖直居中,按钮一律靠右;左侧有说明时说明推到最左。字阶照 Geist 示例实测:标题 20px/600、说明 14px/400——标题必须压过正文。 */.geist-fieldset-title{margin:0 0 10px;color:var(--ink);font-size:var(--fs-xl);font-weight:600}-.cleanupfieldset>.geist-fieldset-footer{box-sizing:border-box;height:var(--fieldset-bar-h);- margin:0;padding:0 16px 0 20px;display:flex;align-items:center;justify-content:flex-end;gap:8px;+.cleanupfieldset>.geist-fieldset-footer{box-sizing:border-box;min-height:var(--fieldset-bar-h);+ margin:0;padding:8px 16px 8px 20px;display:flex;align-items:center;justify-content:flex-end;gap:8px;border-top:1px solid var(--border-10);background:var(--overlay-5)}+/* 说明可以换行、按钮不能被压扁:窄屏下操作条仍是一行,说明占剩下的宽度,+ 条子按内容长高(证据:vercel.com/geist/fieldset 在 375px 下操作条仍是+ flex-direction:row、nowrap,min-height 56px 实测长到 65/85/105px,+ 按钮保持 70–186px 的内容宽度,没有一个铺满)。 */.geist-fieldset-footer>p,.geist-fieldset-footer>span,-.resourcesyncfooter>p,.resourceapplyrow>p{margin-right:auto}-.cleanupfieldset{display:flex;flex-direction:column;min-width:0;min-height:176px;margin:0;padding:0;overflow:hidden;+.resourcesyncfooter>p,.resourceapplyrow>p{min-width:0;margin-right:auto}+/* 没有 min-height:卡片高度由内容决定,和同页的「网盘与账本」一致。三列时那条+ 176px 地板是用来对齐同一行的,改成单列后它只是把每张卡都撑出一段空白。 */+.cleanupfieldset{display:flex;flex-direction:column;min-width:0;margin:0;padding:0;overflow:hidden;border:1px solid var(--line-soft);border-radius:12px;background:var(--surface)}-.cleanupfieldset>.geist-fieldset-content{flex:1;min-height:0;padding:20px}.cleanupfieldset strong{display:block;margin-bottom:10px;font-size:var(--fs-md);font-weight:500;color:var(--ink-2)}+.cleanupfieldset>.geist-fieldset-content{flex:1;min-height:0;padding:20px}.cleanupfieldset strong{display:block;font-size:var(--fs-md);font-weight:500;color:var(--ink-2)}.cleanupfieldset p{margin:0;color:var(--muted);font-size:var(--fs-md);line-height:1.45}-/* 数据管理 fieldset 上的按钮与关注页 .fbtn 同一套白边语言:hover 只提亮描边- 和文字,不出蓝色;危险按钮 hover 沿用 fquiet 的红线做法。 */-.cleanupfieldset button{box-sizing:border-box;min-height:32px;padding:0 12px;border:1px solid var(--border-15);border-radius:var(--control-radius);- background:transparent;color:var(--ink-2);display:inline-flex;align-items:center;justify-content:center;gap:6px;cursor:pointer;+/* 主数字下面那行分项。空着时整行不占位——没有分项的卡不该比别人多一段留白。 */+.cleanupmeta{margin-top:6px;font-size:var(--fs-sm)}+.cleanupmeta:empty{display:none}+/* 操作条上的按钮一律填 --surface:条子本身是 --overlay-5,比它更深的底才让按钮+ 从条子上分出来。原先数据管理这几个是透明底,只有一圈描边,和「网盘与账本」+ 那颗同处一页却是两种按钮。hover 只提亮底色、描边和文字,不出蓝色;+ 危险按钮 hover 沿用 fquiet 的红线做法。 */+.cleanupfieldset button{box-sizing:border-box;flex:none;min-height:32px;padding:0 12px;border:1px solid var(--border-15);border-radius:var(--control-radius);+ background:var(--surface);color:var(--ink-2);display:inline-flex;align-items:center;justify-content:center;gap:6px;cursor:pointer;transition:border-color .12s ease,color .12s ease,background-color .12s ease,scale .1s ease}-.cleanupfieldset button:hover{border-color:var(--ink-2);color:var(--ink)}+.cleanupfieldset button:hover{background:var(--hover);border-color:var(--ink-2);color:var(--ink)}.cleanupfieldset button:active{scale:.96}.cleanupfieldset button.danger{color:var(--drop)}.cleanupfieldset button.danger:hover{border-color:var(--drop);color:var(--drop)}.cleanupfieldset button svg{width:16px;height:16px;stroke:currentColor;fill:none}-.cleanupsources{display:flex;flex-wrap:wrap;gap:6px;margin-top:14px}.cleanupsource{padding:4px 8px;border:1px solid var(--border-15);- border-radius:var(--badge-radius);color:var(--keep);font-size:var(--fs-xs)}.cleanupsource[data-online="false"]{color:var(--muted)}-.cleanupfieldset .cleanupstate{min-height:20px;margin-top:12px;color:var(--ink-2)}+.cleanupfieldset .cleanupstate{margin-top:8px;font-size:var(--fs-sm);color:var(--ink-2)}+.cleanupfieldset .cleanupstate:empty{display:none}.stats h2{margin:0 0 4px;font-size:var(--fs-2xl)}.stats .sub{color:var(--muted);margin:0}@@ -549,6 +559,16 @@ body.photolight-open{overflow:hidden}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}+/* 数据管理是一列 fieldset,不是海报网格:骨架照 fieldset 的轮廓排,+ 否则整页刷新先看到三列 16:9 占位,加载完又整个换成一列长条。+ 底部那条是操作条的位置,不参与呼吸——它是框体,不是待填的内容。 */+.cleanup-skeleton>div{grid-template-columns:minmax(0,1fr);gap:16px}+.cleanup-skeleton .skeletoncard{gap:0;overflow:hidden;border:1px solid var(--line-soft);+ border-radius:12px;background:var(--surface)}+.cleanup-skeleton .skeletoncard i{aspect-ratio:auto;width:38%;height:20px;margin:20px 20px 0}+.cleanup-skeleton .skeletoncard b{width:26%;height:16px;margin:12px 20px 20px}+.cleanup-skeleton .skeletoncard em{width:100%;height:var(--fieldset-bar-h);margin:0;+ border-radius:0;border-top:1px solid var(--border-10);background:var(--overlay-5);animation:none}.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)}@@ -725,7 +745,7 @@ button.serieslink.entitylink:hover{color:var(--tungsten);text-decoration:none}.revieworigin>div button{display:inline-flex;align-items:center;gap:6px;border:0;border-radius:7px;background:var(--hover);padding:6px 9px;color:var(--ink-2);cursor:pointer}.revieworigin>div button:hover{color:var(--tungsten)}.revieworigin>div button svg{width:15px;height:15px;stroke:currentColor;fill:none;stroke-width:2}@media(max-width:640px){.qualitylist{grid-template-columns:1fr}.qualityitem{grid-template-columns:110px minmax(0,1fr)}.qualitycover{width:110px}.reviewcompare{grid-template-columns:1fr}.revieworigin{grid-template-columns:110px minmax(0,1fr)}.revieworigincover{width:110px}}-@media(max-width:640px){.resourcesync .resourcesyncfooter{align-items:stretch;flex-direction:column}.resourcesyncfooter button{width:100%;justify-content:center}.resourcesync .resourcesources{grid-template-columns:1fr}.resourcesync .resourcesources article+article{border-left:0;border-top:1px solid var(--line-soft)}.resourcesync .resourcecache{grid-template-columns:1fr}.resourcesync .resourcecache>div+div{border-left:0;border-top:1px solid var(--line-soft)}.resourcesync .resourceapplyrow{align-items:stretch;flex-direction:column}.resourcesync #resourceApply{width:100%}}+@media(max-width:640px){.resourcesync .resourcesources{grid-template-columns:1fr}.resourcesync .resourcesources article+article{border-left:0;border-top:1px solid var(--line-soft)}.resourcesync .resourcecache{grid-template-columns:1fr}.resourcesync .resourcecache>div+div{border-left:0;border-top:1px solid var(--line-soft)}}.indexmore[hidden],.entitymore[hidden]{display:none}.indexmore,.entitymore{display:flex;align-items:center;justify-content:center;margin:20px auto 0;min-width:124px;@@ -778,7 +798,7 @@ main{position:relative;z-index:1;padding:14px 16px 90px}.count.count-actions-only{position:relative;top:auto;min-height:0;margin:0 0 16px;padding:0;justify-content:flex-end}.count.count-actions-only:empty{display:none}.resourcesync{scroll-margin-top:calc(var(--topH) + 18px);display:grid;gap:16px}.resourcesync>h2{margin:0;font-size:var(--fs-xl)}-.resourcesyncbox,.resourcepanel{overflow:clip;border:1px solid var(--line-soft);border-radius:12px;background:var(--surface)}.resourcesyncbody{padding:20px}.resourcesyncbody p{max-width:760px;margin:0;color:var(--muted);font-size:var(--fs-sm);line-height:1.55}.resourcesyncfooter,.resourceapplyrow{box-sizing:border-box;height:var(--fieldset-bar-h);display:flex;align-items:center;justify-content:flex-end;gap:16px;padding:0 20px;border-top:1px solid var(--line-soft);background:var(--overlay-5)}.resourcesyncfooter p,.resourceapplyrow>p{margin:0;color:var(--muted);font-size:var(--fs-xs);line-height:1.5}.resourceaction{box-sizing:border-box;height:36px;padding:0 12px;border:1px solid var(--border-15);border-radius:var(--control-radius);background:var(--surface);color:var(--ink-2);display:inline-flex;align-items:center;justify-content:center;gap:8px;flex:none;font:inherit;font-size:var(--fs-sm);font-weight:550;cursor:pointer;transition:background-color .12s,border-color .12s,color .12s}.resourceaction:hover:not(:disabled){background:var(--hover);border-color:color-mix(in srgb,var(--ink) 28%,transparent);color:var(--ink)}.resourceaction:focus-visible{outline:2px solid var(--tungsten);outline-offset:2px}.resourceaction:disabled{cursor:default;opacity:.68}.resourceaction svg{width:16px;height:16px;stroke:currentColor;fill:none}#resourceSyncResult:empty{display:none}.resourcescanning,.resourceerror{margin:0;padding:14px 16px;border:1px solid var(--line-soft);border-radius:var(--control-radius);color:var(--muted)}.resourceerror{color:var(--drop)}.resourcesources{display:grid;grid-template-columns:repeat(3,minmax(0,1fr))}.resourcesources article{display:grid;gap:4px;min-width:0;padding:16px}.resourcesources article+article{border-left:1px solid var(--line-soft)}.resourcesourcetitle{display:flex;align-items:center;justify-content:space-between;gap:12px}.resourcesourcetitle span{font-size:var(--fs-xs)}.resourcesources .online{color:var(--success)}.resourcesources .offline{color:var(--drop)}.resourcesources strong{margin-top:10px;font-size:var(--fs-2xl);font-variant-numeric:tabular-nums}.resourcesources small,.resourcecache small{color:var(--muted)}/* 这里是一排读数,不是又一个盒子。原先它自带填色和分格线,和下面的操作条同色,+.resourcesyncbox,.resourcepanel{overflow:clip;border:1px solid var(--line-soft);border-radius:12px;background:var(--surface)}.resourcesyncbody{padding:20px}.resourcesyncbody p{max-width:760px;margin:0;color:var(--muted);font-size:var(--fs-sm);line-height:1.55}.resourcesyncfooter,.resourceapplyrow{box-sizing:border-box;min-height:var(--fieldset-bar-h);display:flex;align-items:center;justify-content:flex-end;gap:16px;padding:8px 20px;border-top:1px solid var(--line-soft);background:var(--overlay-5)}.resourcesyncfooter p,.resourceapplyrow>p{margin:0;color:var(--muted);font-size:var(--fs-xs);line-height:1.5}.resourceaction{box-sizing:border-box;height:36px;padding:0 12px;border:1px solid var(--border-15);border-radius:var(--control-radius);background:var(--surface);color:var(--ink-2);display:inline-flex;align-items:center;justify-content:center;gap:8px;flex:none;font:inherit;font-size:var(--fs-sm);font-weight:550;cursor:pointer;transition:background-color .12s,border-color .12s,color .12s}.resourceaction:hover:not(:disabled){background:var(--hover);border-color:color-mix(in srgb,var(--ink) 28%,transparent);color:var(--ink)}.resourceaction:focus-visible{outline:2px solid var(--tungsten);outline-offset:2px}.resourceaction:disabled{cursor:default;opacity:.68}.resourceaction svg{width:16px;height:16px;stroke:currentColor;fill:none}#resourceSyncResult:empty{display:none}.resourcescanning,.resourceerror{margin:0;padding:14px 16px;border:1px solid var(--line-soft);border-radius:var(--control-radius);color:var(--muted)}.resourceerror{color:var(--drop)}.resourcesources{display:grid;grid-template-columns:repeat(3,minmax(0,1fr))}.resourcesources article{display:grid;gap:4px;min-width:0;padding:16px}.resourcesources article+article{border-left:1px solid var(--line-soft)}.resourcesourcetitle{display:flex;align-items:center;justify-content:space-between;gap:12px}.resourcesourcetitle span{font-size:var(--fs-xs)}.resourcesources .online{color:var(--success)}.resourcesources .offline{color:var(--drop)}.resourcesources strong{margin-top:10px;font-size:var(--fs-2xl);font-variant-numeric:tabular-nums}.resourcesources small,.resourcecache small{color:var(--muted)}/* 这里是一排读数,不是又一个盒子。原先它自带填色和分格线,和下面的操作条同色,两条带子连在一起看不出边界;框里再套框也是多余的一层。 */.resourcecache{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 32px;border-top:1px solid var(--line-soft);padding:16px 20px}.resourcecache>div{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:baseline;gap:4px 16px}.resourcecache b{font-size:var(--fs-2xl);font-variant-numeric:tabular-nums}.resourcecache span{font-weight:650}.resourcecache small{grid-column:1/-1}.resourceapplyrow .resourcesyncok{color:var(--success)}.resourcedanger{color:var(--drop)}.resourcedanger:hover:not(:disabled){border-color:color-mix(in srgb,var(--drop) 42%,transparent);background:color-mix(in srgb,var(--drop) 8%,transparent);color:var(--drop)}.resourcesyncok{margin:0;color:var(--success)}.tagbar,.count,.entitytagbar,.entitycollectionhead{transition:background-color .16s ease,border-color .16s ease}@@ -1762,7 +1782,6 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位.runtimegate a{grid-column:2/-1}.managebar-menu button{width:100%;min-height:42px;justify-content:flex-start;padding:9px 11px}.cleanupgrid{grid-template-columns:minmax(0,1fr)}- .cleanupfieldset{min-height:176px}.grid{gap:16px 8px}.count{align-items:center;flex-direction:row;gap:10px;padding-block:8px;overflow-x:auto;overflow-y:hidden;scrollbar-width:none;overscroll-behavior-inline:contain}diff --git a/web/app.js b/web/app.jsindex c60c32fb2..49a1219f7 100644--- a/web/app.js+++ b/web/app.js@@ -22,8 +22,25 @@ function renderCatalogLoading(label='正在读取作品'){count.textContent='';count.setAttribute('aria-label',label);$('#grid').innerHTML=pageSkeletonHtml(label,{cards:true,className:'catalog-skeleton'});}-/* 深链启动前先占住目标表面。后续路由仍画同一种 Skeleton,因此不会先出现首页- Spinner、再切成目标页 Loading Dots。 */+/* 每个管理表面的加载态只有一份定义,深链启动和路由到位后都从这里取。+ 两处各写各的时,整页刷新会连播两段动画:先一张通用大布局骨架,再各页自己的+ 加载态(数据管理那张还是 Loading Dots)。取同一份,键就相同,+ showManagementBody 认出是同一张后不再重画。 */+const MANAGEMENT_PLACEHOLDERS={+ '/stats':()=>`<div class="insightpage">${pageSkeletonHtml('正在读取统计',{variant:'dashboard'})}</div>`,+ '/taste':()=>`<div class="tastepage">${pageSkeletonHtml('正在读取口味分析')}</div>`,+ '/data-cleanup':()=>`<div class="cleanuppage">${+ pageSkeletonHtml('正在读取数据管理状态',{cards:true,className:'cleanup-skeleton'})}</div>`,+ // /resource-sync 只是数据管理页上的一个锚点,启动时占位也该是数据管理那张。+ '/resource-sync':()=>MANAGEMENT_PLACEHOLDERS['/data-cleanup'](),+ '/duplicates':()=>pageSkeletonHtml('正在比对重复内容',{cards:true}),+ '/review':()=>pageSkeletonHtml('正在读取复核队列',{cards:true}),+ '/quality-goals':()=>pageSkeletonHtml('正在读取高清版目标',{cards:true}),+ '/playlists':()=>pageSkeletonHtml('正在读取播放列表',{cards:true}),+ '/follow-manage':()=>`<div class="follow">${pageSkeletonHtml('正在读取关注管理',{cards:true})}</div>`,+};+const managementPlaceholder=path=>+ (MANAGEMENT_PLACEHOLDERS[path]||(()=>pageSkeletonHtml('正在读取页面')))();function renderInitialSurfaceLoading(){const path=decodeURIComponent(location.pathname);if(path==='/junk-files'){@@ -36,9 +53,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=path.startsWith('/follow')+ stats.innerHTML=path.startsWith('/follow')&&path!=='/follow-manage'?followSkeletonHtml('正在读取关注内容')- :pageSkeletonHtml('正在读取页面');+ :managementPlaceholder(path);return;}if(path==='/performers'||path==='/creators'||path==='/tags'||@@ -1840,12 +1857,18 @@ function wireLoadMore(button, load){{rootMargin:'320px'});button._observer.observe(button);}+const skeletonKeyOf=html=>String(html).match(/data-skeleton="([^"]*)"/)?.[1]||'';function showManagementBody({manage=true,placeholder=''}={}){$('#stats').hidden=false;$('#index').hidden=true;$('#grid').innerHTML='';$('#count').textContent='';$('#loadSentinel').hidden=true;$('#shortsSec').hidden=true;if(manage)buildManageBar();else{$('#managebar').hidden=true;$('#manageTitle').hidden=true;buildEdge()}- if(placeholder)$('#stats').innerHTML=placeholder;+ if(!placeholder)return;+ /* 屏幕上已经是同一张骨架就别重画:innerHTML 换新节点会把 shimmer 从头放一遍,+ 整页刷新看到的就是同一段动画闪两次。 */+ const painted=$('#stats').querySelector('[data-skeleton]')?.dataset.skeleton||'';+ const next=skeletonKeyOf(placeholder);+ if(!next||next!==painted)$('#stats').innerHTML=placeholder;}function showIndexLoading(label){$('#stats').hidden=true;$('#index').hidden=false;$('#grid').innerHTML='';@@ -1865,8 +1888,7 @@ async function openStats(push=true){const surface=claimSurface('/stats');enterManagementSurface();disposeStage(false);- showManagementBody({placeholder:`<div class="insightpage">${- pageSkeletonHtml('正在读取统计',{variant:'dashboard'})}</div>`});+ showManagementBody({placeholder:managementPlaceholder('/stats')});const d=await api('/api/stats');if(!surfaceCurrent(surface))return;showManagementBody();@@ -2285,7 +2307,7 @@ async function openTaste(push=true){const cachedEntry=tasteCache.get(tasteWindow),cached=cachedEntry?.dashboard;const cacheFresh=cached&&Date.now()-cachedEntry.at<TASTE_CACHE_FRESH_MS;if(cached)renderTaste(cached);- else $('#stats').innerHTML=`<div class="tastepage">${pageSkeletonHtml('正在读取口味分析')}</div>`;+ else showManagementBody({placeholder:managementPlaceholder('/taste')});if(!cacheFresh){const request=++tasteRequest;const requestedWindow=tasteWindow;@@ -2353,7 +2375,7 @@ async function openPlaylists(push=true){releaseHoverPreviews();disposeStage(false);enterManagementSurface();if(push)route('/playlists');const surface=claimSurface('/playlists');- showManagementBody({manage:false,placeholder:pageSkeletonHtml('正在读取播放列表',{cards:true})});+ showManagementBody({manage:false,placeholder:managementPlaceholder('/playlists')});const data=await api('/api/playlists');if(!surfaceCurrent(surface))return;showManagementBody({manage:false});@@ -2387,35 +2409,49 @@ async function openDataCleanup(push=true){releaseHoverPreviews();disposeStage(false);enterManagementSurface();if(push)route('/data-cleanup');const surface=claimSurface('/data-cleanup');- showManagementBody({placeholder:`<div class="cleanuploading">${loadingDotsHtml('正在读取数据管理状态…')}</div>`});+ showManagementBody({placeholder:managementPlaceholder('/data-cleanup')});const [junk,duplicates,sources]=await Promise.all([api('/api/ads?limit=1'),api('/api/duplicates?limit=1'),api('/api/sources'),]);if(!surfaceCurrent(surface))return;paintManageLede();- const sourceState=(sources.sources||[]).filter(source=>['local','115','pikpak'].includes(source.location)).map(source=>- `<span class="cleanupsource" data-online="${source.online?'true':'false'}">${esc(LOC[source.location]||source.location)} · ${source.online?'在线':'离线'}</span>`).join('');+ /* 三个「· 在线」徽章换成一行来源名:卡片要说的是这次会扫哪几个来源,+ 来源在线与否是资源同步那一块的读数,在这里只有离线时才改变结论。 */+ const scanSources=(sources.sources||[]).filter(source=>['local','115','pikpak'].includes(source.location));+ const sourceName=source=>esc(LOC[source.location]||source.location);+ const online=scanSources.filter(source=>source.online),offline=scanSources.filter(source=>!source.online);+ const sourceLine=[online.map(sourceName).join(' · '),+ offline.length?`${offline.map(sourceName).join(' · ')} 离线`:''].filter(Boolean).join(' · ');+ const junkCounts=junk.counts||{};+ const junkBreakdown=[...JUNK_KIND_OPTIONS.filter(([key])=>key&&Number(junkCounts[key])>0)+ .map(([key,label])=>`${esc(label)} ${Number(junkCounts[key]).toLocaleString()}`),+ ...(Number(junk.dismissed_total)>0?[`已忽略 ${Number(junk.dismissed_total).toLocaleString()}`]:[])].join(' · ');$('#stats').innerHTML=`<div class="cleanuppage"><div class="cleanupgrid"><section class="cleanupfieldset" data-geist-fieldset aria-labelledby="cleanupJunkTitle"><div class="geist-fieldset-content">${fieldsetTitle('cleanupJunkTitle','垃圾文件')}- <strong>${Number(junk.pending_total||0).toLocaleString()} 个待判断</strong></div>+ <strong>${Number(junk.pending_total||0).toLocaleString()} 个待判断</strong>+ <p class="cleanupmeta">${junkBreakdown}</p></div><footer class="geist-fieldset-footer" data-geist-fieldset-footer><button type="button" data-cleanup-open="junk">查看垃圾文件</button></footer></section><section class="cleanupfieldset" data-geist-fieldset aria-labelledby="cleanupDupTitle"><div class="geist-fieldset-content">${fieldsetTitle('cleanupDupTitle','重复文件')}- <strong>${Number(duplicates.total||0).toLocaleString()} 组 · ${Number(duplicates.files||0).toLocaleString()} 个文件</strong></div>+ <strong>${Number(duplicates.total||0)+ ?`${Number(duplicates.total).toLocaleString()} 组 · ${Number(duplicates.files||0).toLocaleString()} 个文件`+ :'没有重复内容'}</strong>+ <p class="cleanupmeta">${Number(duplicates.total||0)?`可回收 ${fmtSize(duplicates.reclaimable||0)}`:''}</p></div><footer class="geist-fieldset-footer" data-geist-fieldset-footer><button type="button" data-cleanup-open="duplicates">查看重复文件</button></footer></section><section class="cleanupfieldset cleanupemptyfolders" data-geist-fieldset aria-labelledby="cleanupEmptyTitle"><div class="geist-fieldset-content">${fieldsetTitle('cleanupEmptyTitle','空文件夹')}- <p>不会删除来源根目录。</p>- <div class="cleanupsources">${sourceState}</div><p class="cleanupstate" aria-live="polite"></p></div>+ <strong>${online.length.toLocaleString()} 个来源可扫描</strong>+ <p class="cleanupmeta">${sourceLine}</p><p class="cleanupstate" aria-live="polite"></p></div><footer class="geist-fieldset-footer" data-geist-fieldset-footer><button type="button" class="danger" data-cleanup-empty>${icon('trash')}<span>删除空文件夹</span></button></footer></section>${DATA_MANAGEMENT_ENTRIES.map(([section,title,label])=>`<section class="cleanupfieldset" data-geist-fieldset aria-labelledby="cleanup-${section}-title"><div class="geist-fieldset-content">${fieldsetTitle(`cleanup-${section}-title`,title)}- <strong data-cleanup-count="${section}">—</strong></div>+ <strong data-cleanup-count="${section}">—</strong>+ <p class="cleanupmeta" data-cleanup-meta="${section}"></p></div><footer class="geist-fieldset-footer" data-geist-fieldset-footer><button type="button" data-cleanup-go="${section}">${esc(label)}</button></footer></section>`).join('')}</div>@@ -2452,25 +2488,40 @@ const DATA_MANAGEMENT_ENTRIES=[['trash','回收站','查看回收站'],['quality','高清版','查看高清版'],];-/* 计数各自失败各自算:复核接口出错不该把回收站那张卡也变成「—」。 */+/* 计数各自失败各自算:复核接口出错不该把回收站那张卡也变成「—」。+ 第二行是同一份 payload 里已经有的分项,不额外发请求。 */async function paintDataManagementCounts(){- const write=(section,text)=>{- const el=$('#stats')?.querySelector(`[data-cleanup-count="${section}"]`);- if(el)el.textContent=text;+ const write=(section,text,meta='')=>{+ const root=$('#stats');+ const count=root?.querySelector(`[data-cleanup-count="${section}"]`);+ if(count)count.textContent=text;+ const line=root?.querySelector(`[data-cleanup-meta="${section}"]`);+ if(line)line.textContent=meta;};const fill=async(section,load)=>{- try{write(section,await load())}catch(_error){write(section,'读取失败')}+ try{const [text,meta='']=await load();write(section,text,meta)}+ catch(_error){write(section,'读取失败')}};await Promise.all([fill('review',async()=>{const data=await api('/api/review?counts=1');- const total=Object.values(data.counts||{}).reduce((sum,value)=>sum+(Number(value)||0),0);- return `${total.toLocaleString()} 条待复核`;+ const counts=Object.entries(data.counts||{})+ .map(([key,value])=>[REVIEW_LABELS[key]||key,Number(value)||0])+ .filter(([,value])=>value>0).sort((a,b)=>b[1]-a[1]);+ const total=counts.reduce((sum,[,value])=>sum+value,0);+ // 只列前三类,剩下的合成一项:卡片是入口,不是复核队列本身。+ const top=counts.slice(0,3).map(([label,value])=>`${label} ${value.toLocaleString()}`);+ const rest=counts.slice(3).reduce((sum,[,value])=>sum+value,0);+ if(rest)top.push(`其余 ${rest.toLocaleString()}`);+ return [`${total.toLocaleString()} 条待复核`,top.join(' · ')];+ }),+ fill('trash',async()=>{+ const data=await api('/api/items?state=trash&limit=1');+ const total=Number(data.total||0);+ return [`${total.toLocaleString()} 项在回收站`,total?`占用 ${fmtSize(data.bytes||0)}`:''];}),- fill('trash',async()=>- `${Number((await api('/api/items?state=trash&limit=1')).total||0).toLocaleString()} 项在回收站`),fill('quality',async()=>- `${Number((await api('/api/quality-goals?limit=1')).total||0).toLocaleString()} 个待升级`),+ [`${Number((await api('/api/quality-goals?limit=1')).total||0).toLocaleString()} 个待升级`]),]);}@@ -2482,7 +2533,7 @@ async function openDuplicates(push=true){releaseHoverPreviews();disposeStage(false);enterManagementSurface();if(push)route('/duplicates');const surface=claimSurface('/duplicates');- showManagementBody({placeholder:pageSkeletonHtml('正在比对重复内容',{cards:true})});+ showManagementBody({placeholder:managementPlaceholder('/duplicates')});const next=await api('/api/duplicates?limit=120');if(!surfaceCurrent(surface))return;dupData=next;@@ -2560,7 +2611,7 @@ async function openReview(push=true){releaseHoverPreviews();disposeStage(false);enterManagementSurface();if(push)route('/review');const surface=claimSurface('/review');- showManagementBody({placeholder:pageSkeletonHtml('正在读取复核队列',{cards:true})});+ showManagementBody({placeholder:managementPlaceholder('/review')});const runtime=await api('/healthz');if(!surfaceCurrent(surface))return;/* ADR-0018:确定的那部分先落库再取队列。reader 明知不能写就不要制造一次 409;@@ -2699,7 +2750,7 @@ async function openQualityGoals(push=true){releaseHoverPreviews();disposeStage(false);enterManagementSurface();if(push)route('/quality-goals');const surface=claimSurface('/quality-goals');- showManagementBody({placeholder:pageSkeletonHtml('正在读取高清版目标',{cards:true})});+ showManagementBody({placeholder:managementPlaceholder('/quality-goals')});const next=await api('/api/quality-goals?limit=200');if(!surfaceCurrent(surface))return;qualityData=next;@@ -3815,7 +3866,7 @@ async function openFollowManage(push=true){followManageSort=['checked','added','name','sources'].includes(requested)?requested:'checked';}const surface=claimSurface('/follow-manage');- showManagementBody({placeholder:`<div class="follow">${pageSkeletonHtml('正在读取关注管理',{cards:true})}</div>`});+ showManagementBody({placeholder:managementPlaceholder('/follow-manage')});const [data,credentials,runtime]=await Promise.all([api('/api/follow?limit=1'),api('/api/follow/credentials'),api('/healthz')]);if(!surfaceCurrent(surface))return;diff --git a/web/js/ui-components.js b/web/js/ui-components.jsindex 6e16f0b79..0bb504bbb 100644--- a/web/js/ui-components.js+++ b/web/js/ui-components.js@@ -105,7 +105,10 @@ export function skeletonHtml(label='正在读取内容',{className='',variant='p<span class="skeleton" style="width:100%"></span><span class="skeleton" style="width:100%"></span><span class="skeleton" style="width:72%"></span>`;+ /* data-skeleton 是这张骨架的身份。深链启动先画一张、路由到位后各页再画一张,+ 整页刷新就会连闪两段动画;调用方拿这个键判断「已经是同一张了」,跳过重画。 */return `<div class="skeletonpanel skeleton-${kind}${className?` ${esc(className)}`:''}"+ data-skeleton="${esc(kind)}${className?`/${esc(className)}`:''}"role="status" aria-label="${esc(label)}"><span class="sr-only">${esc(label)}</span><div aria-hidden="true">${body}</div></div>`;}