Peach: Local-first video metadata scraper and media manager.
feat(web): 数据管理归并一处,界面口径说明整批清退
longmeidaocb0611d8fe38
diff --git a/.claude/skills/peach-web-ui/SKILL.md b/.claude/skills/peach-web-ui/SKILL.mdindex d059daca5..556b95d23 100644--- a/.claude/skills/peach-web-ui/SKILL.md+++ b/.claude/skills/peach-web-ui/SKILL.md@@ -5,7 +5,7 @@ description: 在新增、修改或复核 Peach 页面、控件、提示、错误# Peach Web UI 复用门槛-最后复核:2026-08-31+最后复核:2026-09-01## 开工顺序@@ -51,7 +51,9 @@ description: 在新增、修改或复核 Peach 页面、控件、提示、错误- 分页末尾、空页和“没有更多内容”是中性终止状态,用可关闭 Note;只有需要恢复或处理的故障才能进入红色 error Note。- 弹层标题栏与滚动正文分层:标题分隔线属于卡片全宽,滚动条只属于正文。- 没有直接证据不得新增动效;参考产品无动画的菜单保持无动画。-- Fieldset 的正文统一 20px 内边距,Footer 最小 56px、上/右/下 12px、左 20px;同组卡片必须同高,变化内容只放一个纵向 Scroller。+- Fieldset 的正文统一 20px 内边距;标题条与底部操作条同为 `--fieldset-bar-h`(52px)、竖直居中、左 20px 右 16px。标题放在框体里,不用原生 `<legend>`:它会在上边框上开缺口,同组卡片内容高度不同时缺口位置也跟着不齐。同组卡片必须同高,变化内容只放一个纵向 Scroller。+- 界面不解释数字是怎么算出来的。口径、免责、隐私声明、「不会做什么」和「按什么汇总」都不写:这个库只有一个用户,定口径的就是他本人。只留他要据以决定或操作的东西——读数本身、不可逆动作的作用范围、正在发生的事。单位跟着数字走(`497 项`),不另起一行说明。+- 上一次跑完的结果不常态显示。它是那一刻的快照,进页面就铺开会被读成现在的状态,而页面上没有任何东西说它是旧的;只有仍在进行的任务才自动接管页面。- Empty State 的标题和说明必须同处组件内;全页空态与上方工具条统一留 16px,不得再套一层空卡片。- 任何先请求再重绘整页的入口都必须绑定导航代际;只比较 `location.pathname` 不能防住“离开后快速返回同一路径”的旧响应。diff --git a/src/peach/web_contract.py b/src/peach/web_contract.pyindex b4027ce56..cd21d9f34 100644--- a/src/peach/web_contract.py+++ b/src/peach/web_contract.py@@ -2249,8 +2249,15 @@ def _get_taste(contract, args):)-def _get_review(contract, _args):- return contract.cached("review", lambda: q_review(contract))+def _get_review(contract, args):+ payload = contract.cached("review", lambda: q_review(contract))+ # 数据管理页只要一个待复核条数。完整 payload 带着每条候选的全文,实测是+ # 兆级;卡片上的一个数字不值这趟传输,但计数本身仍来自同一份缓存快照,+ # 不另立一套口径。+ if str(args.get("counts") or "") in {"1", "true"}:+ return {key: payload[key] for key in ("counts", "sources", "skipped_rows")+ if key in payload}+ return payloaddef _post_empty_trash(contract, _body):diff --git a/tests/test_follow_web.py b/tests/test_follow_web.pyindex 1b92a6ff6..770533ee4 100644--- a/tests/test_follow_web.py+++ b/tests/test_follow_web.py@@ -2102,7 +2102,7 @@ class FollowWebSourceTests(unittest.TestCase):# 回执带一个具名的后续动作:光摆数字会让人去点「…条详情」那半句,# 文案里不再留悬空的「详情」,去看更新作为显式按钮接住这个意图。self.assertPageContains("action:{label:'去看更新',run:()=>openFollow()}")- self.assertPageContains("if(action)item.querySelector('.tact')")+ self.assertPageContains("if(act)act.onclick=()=>{setActionBusy(act);action.run()};")self.assertPageLacks("条详情")def test_follow_bulk_actions_are_buttons_not_inline_links(self):diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex 551c3541a..252f29d10 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -360,6 +360,40 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains("if(later){e.stopPropagation();setActionBusy(later)")self.assertPageContains("if(kind==='o')await post('o-undo')")+ def test_undo_reports_back_on_the_same_toast_instead_of_swapping_two(self):+ """撤销原先是「关掉回执 + 另发一条已撤销」。++ 底部对齐的栈里一进一出,剩下那条会整块跳一格;撤销请求快过退场动画时+ 两条还会同时在场。结果写回同一条 toast 就没有这次进出。+ """+ self.assertPageContains("item.replaceMessage=(body,{warn:alert=false,timeout:next=4000}={})")+ self.assertPageContains("try{await undo();item.replaceMessage('已撤销')}")+ self.assertPageContains("if(act)act.onclick=()=>{setActionBusy(act);action.run()};")+ self.assertPageLacks("try{await undo();toast('已撤销')}")+ # 退场先把高度写死再过渡到 0;直接 remove() 会让上面那条瞬间落下来。+ self.assertPageContains("item.style.height=`${item.offsetHeight}px`;item.getBoundingClientRect();")+ self.assertPageContains(".toast.leaving{height:0!important;margin-top:0;padding-block:0;")+ # 行距改成每条自己的上外边距:gap 属于容器,收不进这次过渡。+ self.assertPageContains(".toast{pointer-events:auto;box-sizing:border-box;display:flex;align-items:center;")+ self.assertPageLacks(".toasts{position:fixed;right:16px;bottom:22px;z-index:var(--layer-popover);display:grid;gap:8px;")++ def test_scrollbar_gutter_is_reserved_so_overlays_do_not_shift_the_page(self):+ """设置面板给 body 加 overflow:hidden,滚动条一消失整页就横向跳一次。"""+ self.assertPageContains("scrollbar-gutter:stable}")+ self.assertPageContains("body.settings-open{overflow:hidden}")++ def test_closing_a_deep_linked_player_reloads_the_home_feed(self):+ """直接打开 /parts/28125/28125 后关闭播放器,首页停在骨架上再也不动。++ 判据原先是「`#grid` 有没有子节点」,而深链启动时网格里正躺着一个还没被+ 替换掉的加载骨架——它也是子节点,于是「退回去有东西可看」被判成真,+ `route('/')` 只改了地址栏。卡片一定带 data-id,骨架没有。+ """+ self.assertPageContains("function hasReturnSurface()")+ self.assertPageContains("return !!$('#grid').querySelector('[data-id],[data-mix-seed]')")+ self.assertPageContains("const returnSurfaceReady=hasReturnSurface();")+ self.assertPageLacks("const returnSurfaceReady=$('#grid').children.length>0")+def test_detail_like_reason_is_an_icon_disclosure_without_idle_explanation(self):self.assertPageContains('id="preferenceToggle" aria-label="喜爱理由"')self.assertPageContains('id="preferencePanel" hidden')@@ -934,7 +968,7 @@ class WebUiSourceTests(unittest.TestCase):"""self.assertPageContains("['manage','管理','database']")self.assertPageContains("const MANAGE_SECTIONS=[")- for section in ("'stats','统计'", "'cleanup','数据清理'",+ for section in ("'stats','统计'", "'cleanup','数据管理'","'quality','高清版'", "'trash','回收站'", "'review','人工复核'","'taste','口味'"):self.assertPageContains(section)@@ -953,18 +987,43 @@ class WebUiSourceTests(unittest.TestCase):self.assertNotIn(gone, edge, f"{gone} 应该已经收进管理,不再是顶层入口")self.assertIn("'manage'", edge)- def test_manage_sections_follow_the_order_work_actually_happens_in(self):- """导航条的顺序就是做事顺序:先收拾库里已有的,再看要往外拿什么。+ def test_manage_menu_only_offers_pages_that_are_not_inside_data_management(self):+ """人工复核、回收站、高清版都从数据管理进,管理菜单里不再各占一行。- 关注(原「追更来源」)曾夹在高清版和回收站中间,人工复核掉到最末尾,- 两者都不挨着自己那一组。+ 它们和垃圾文件、重复文件、空文件夹是同一件事的不同步骤。身份注册表仍然+ 保留全部页面:URL 要能直达,用户也仍可把其中任何一个钉到顶层侧栏。"""sections = self.page.split("const MANAGE_SECTIONS=[", 1)[1].split("];", 1)[0]order = [line.split("'")[1] for line in sections.splitlines() if line.strip().startswith("['")]self.assertEqual(order, ["stats", "taste", "review", "cleanup", "trash", "follow", "quality"],- "管理导航的顺序是语义契约:现状 → 复核 → 清理 → 回收站 → 往外拿",+ "身份注册表保留全部管理页,删掉哪一个就等于让它的标题和直达 URL 一起失效",)+ self.assertPageContains(+ "const MANAGE_MENU_SECTIONS=['stats','taste','cleanup','follow'];")+ self.assertPageContains("manageMenuSections().map(([k,label,ic])=>")++ def test_data_management_is_the_single_entry_for_tidying_the_library(self):+ """复核、回收站、高清版和链接管理、资源同步都归到数据管理这一页。++ 资源同步和链接管理此前挂在统计页上——它们改的是账本和外部现实的对齐,+ 跟「库里现在有多少」不是一件事。+ """+ self.assertPageContains("const DATA_MANAGEMENT_ENTRIES=[")+ for entry in ("['review','人工复核'", "['trash','回收站'", "['quality','高清版'"):+ self.assertPageContains(entry)+ self.assertPageContains("button.onclick=()=>openManage(button.dataset.cleanupGo)")+ self.assertPageContains("async function paintDataManagementCounts()")+ self.assertPageContains("api('/api/review?counts=1')")+ # 三个计数各自失败各自算:一个接口出错不该把另外两张卡也变成「—」。+ self.assertPageContains("catch(_error){write(section,'读取失败')}")+ cleanup = self.page.split("async function openDataCleanup(", 1)[1].split("let dupData=null;", 1)[0]+ self.assertIn("${linkManagerMarkup()}", cleanup)+ self.assertIn("${resourceSyncMarkup()}", cleanup)+ stats = self.page.split("async function openStats(", 1)[1].split("function showHomeSurfaces(", 1)[0]+ self.assertNotIn("linkManagerMarkup()", stats,+ "统计页只讲库里现在有多少,不该再挂对齐外部现实的面板")+ self.assertNotIn("resourceSyncMarkup()", stats)def test_taste_page_combines_private_exports_and_peach_behavior(self):self.assertPageContains("if(path==='/taste'){await openTaste(false);return}")@@ -972,9 +1031,13 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains("/api/taste/import")self.assertPageContains("/api/taste/refresh")self.assertPageContains("/api/taste/source")- self.assertPageContains("原始 URL、标题与搜索内容不会显示在页面")- self.assertPageContains("noteHtml('“不合口味”只记录到具体项目与理由,不自动给标签降权。',{className:'tastefootnote tastenegative'})")- self.assertPageContains("noteHtml('原始 URL、标题与搜索内容不会显示在页面,也不会写入 ledger;所有画像均为候选。',{className:'tastefootnote tasteprivacy'})")+ # 口径与免责说明整体清退:这些句子解释的是数字怎么算出来的,+ # 而这个库只有一个用户,他本人就是定这套口径的人。+ self.assertPageLacks("原始 URL、标题与搜索内容不会显示在页面")+ self.assertPageLacks("浏览器记录是当前分析主体")+ self.assertPageLacks("按真实挂载位置汇总")+ self.assertPageLacks("播放、评分与明确反馈保持独立")+ self.assertPageLacks("不自动给标签降权")self.assertPageContains("data-taste-window")self.assertPageContains("data-taste-remove")self.assertPageContains('role="radiogroup" aria-label="口味证据来源"')@@ -987,7 +1050,6 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains('data-taste-dimension="${source}:${key}"')self.assertPageContains("sourceTabs('browser',[['tags','标签']")self.assertPageContains("sourceTabs('peach',[['tags','标签'],['creators','创作者'],['performers','女优']])")- self.assertPageContains("不自动给标签降权")self.assertPageContains("rank.browser_tags||[]")self.assertPageContains("rank.peach_performers||rank.performers||[]")self.assertPageContains("visual==='domain'")@@ -998,7 +1060,6 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains("'hanime1.me':'https://vdownload.hembed.com/image/icon/tab_logo.png")self.assertPageContains("'kemono.cr':'https://kemono.cr/assets/favicon-CPB6l7kH.ico'")self.assertPageContains("const faviconFallbackUrl=domain=>`https://www.google.com/s2/favicons")- self.assertPageContains("支持 macOS / Windows 的 Zen、Safari、Firefox、Chrome")self.assertPageLacks("negative_tags")self.assertPageContains(".tastehero{margin-bottom:16px}")self.assertPageContains(".tasteranks{display:grid;grid-template-columns:repeat(3")@@ -1438,7 +1499,7 @@ class WebUiSourceTests(unittest.TestCase):def test_ads_icon_matches_the_lucide_stroke_style(self):"""图标库里没有表示广告的图形,自绘的感叹号必须和其余图标同风格。"""self.assertPageContains('<symbol id="i-alert" viewBox="0 0 24 24">')- self.assertPageContains("['cleanup','数据清理','hard-drive']")+ self.assertPageContains("['cleanup','数据管理','hard-drive']")def test_pending_delete_is_visible_without_deleting_media(self):self.assertPageContains("it.disposal==='trash'?'pending-delete':''")@@ -2237,15 +2298,24 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains("async function openDataCleanup(push=true)")self.assertPageContains("route('/data-cleanup')")self.assertPageContains("api('/api/ads?limit=1'),api('/api/duplicates?limit=1'),api('/api/sources')")- for legend in ("<legend>垃圾文件</legend>", "<legend>重复文件</legend>",- "<legend>空文件夹</legend>"):- self.assertPageContains(legend)- self.assertPageContains('class="cleanupfieldset" data-geist-fieldset')+ # 标题在框体里,不用原生 legend——legend 会在上边框上开个缺口,+ # 三张卡内容高度不同时那道缺口的位置也跟着不齐。+ for title in ("fieldsetHeader('cleanupJunkTitle','垃圾文件')",+ "fieldsetHeader('cleanupDupTitle','重复文件')",+ "fieldsetHeader('cleanupEmptyTitle','空文件夹')"):+ self.assertPageContains(title)+ self.assertPageLacks("<legend>垃圾文件</legend>")+ self.assertPageContains('class="cleanupfieldset" data-geist-fieldset aria-labelledby=')self.assertPageContains('class="cleanupfieldset cleanupemptyfolders" data-geist-fieldset')self.assertPageContains("api('/api/data-cleanup/empty-folders',{method:'POST',body:'{}'})")self.assertPageContains("来源根目录不会删除")self.assertPageContains(".cleanupfieldset>.geist-fieldset-content{flex:1;min-height:0;padding:20px}")- self.assertPageContains("min-height:56px;margin:0;padding:12px 12px 12px 20px")+ # 头尾两条横条同一份尺寸口径,文字与按钮竖直居中。+ self.assertPageContains("--fieldset-bar-h:52px;")+ self.assertPageContains(+ ".geist-fieldset-header,.cleanupfieldset>.geist-fieldset-footer{box-sizing:border-box;")+ self.assertPageContains("height:var(--fieldset-bar-h);margin:0;padding:0 16px 0 20px;"+ "display:flex;align-items:center;gap:8px}")self.assertPageContains("if(path==='/data-cleanup'){await openDataCleanup(false);return}")def test_duplicate_batch_keeps_one_per_cluster_not_one_per_code(self):@@ -2963,24 +3033,24 @@ class WebUiSourceTests(unittest.TestCase):# 在线资产是 URL,没有本地文件可定位。self.assertPageContains("it.location==='online'?'':`<div class=\"srctools detailtitletools\">${sourceToolButtons(it.id)}</div>`")- def test_resource_sync_is_embedded_in_stats_and_keeps_offline_sources_safe(self):+ def test_resource_sync_lives_in_data_management_and_keeps_offline_sources_safe(self):self.assertPageContains("${resourceSyncMarkup()}")self.assertPageContains("if(path==='/resource-sync'){await openResourceSync(false);return}")- self.assertPageContains("route('/stats#resource-sync',true)")+ self.assertPageContains("route('/data-cleanup#resource-sync',!push)")self.assertPageContains("api('/api/resource-sync/scan',{method:'POST'")self.assertPageContains("api('/api/resource-sync/apply',{method:'POST'")self.assertPageContains("source.unreadable")self.assertPageContains("background:true,restart:true")self.assertPageContains("payload.status==='running'")- self.assertPageContains("location.pathname==='/stats'")+ self.assertPageContains("location.pathname==='/data-cleanup'")self.assertPageContains("background:true,status_only:true")- self.assertPageContains("void followScan(existing)")- self.assertPageContains("离线来源会整库跳过")+ # 上一轮跑完的结果是那一刻的快照。进页面就铺开会被读成现在的账本状态,+ # 而页面上没有任何东西说它是旧的。+ self.assertPageContains("if(existing.status==='running')void followScan(existing);")self.assertPageContains("同步并清理")- self.assertPageContains('class="resourcesyncfooter"')+ self.assertPageContains('class="resourcesyncfooter geist-fieldset-footer"')self.assertPageContains('class="resourcepanel"')self.assertPageContains('class="resourceapplyrow"')- self.assertPageContains("候选 CSV、来源证据、女优头像和厂牌 Logo 不会删除")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}")diff --git a/web/app.css b/web/app.cssindex 29e32663d..b9a44d875 100644--- a/web/app.css+++ b/web/app.css@@ -18,6 +18,9 @@用户以为可以点。 */--pill-radius:999px; --tag-radius:var(--pill-radius);--control-radius:6px; --badge-radius:4px; --floating-radius:12px; --tag-pad-y:4px; --tag-pad-x:10px; --ambient-opacity:0; --hover-delay:5s;+ /* 框体上下两条横条的统一高度。写成变量是因为它同时管数据管理的卡片、链接管理+ 和资源同步:这三处任何一处单独调,页面上就会出现两种「同一种条」。 */+ --fieldset-bar-h:52px;--layer-dialog:1000; --layer-popover:1100; --layer-tooltip:1200;--frost-panel:rgba(247,248,250,.92); --frost-light:rgba(255,255,255,.86);--overlay-5:rgba(20,22,26,.05);--border-10:rgba(20,22,26,.10);--border-15:rgba(20,22,26,.15);@@ -47,7 +50,9 @@*,*::before,*::after{box-sizing:border-box}.sr-only{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}-html{color-scheme:light;scroll-padding-top:calc(var(--topH) + 8px)}+/* 滚动条槽位一直留着。设置面板、灯箱和播放器都会给 body 加 overflow:hidden,+ 槽位不预留时滚动条一消失,整页就横向跳一次;关掉再跳回来。 */+html{color-scheme:light;scroll-padding-top:calc(var(--topH) + 8px);scrollbar-gutter:stable}@media (prefers-color-scheme:dark){html:not([data-theme="light"]){color-scheme:dark}}html[data-theme="dark"]{color-scheme:dark}html,body{margin:0;padding:0}@@ -248,13 +253,17 @@ button[aria-busy="true"],[role="button"][aria-busy="true"]{.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}.cleanupgrid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;padding:0 0 42px}-.cleanupfieldset{display:flex;flex-direction:column;min-width:0;min-height:250px;margin:0;padding:0;overflow:hidden;+/* 框体的上下两条横条只有一份尺寸口径:52px、竖直居中。三张卡内容高度不同时+ 仍然共用同一行网格,不会一张比一张矮半格。 */+.geist-fieldset-header,.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;gap:8px}+.geist-fieldset-header{border-bottom:1px solid var(--border-10)}+.geist-fieldset-header h3{margin:0;color:var(--ink);font-size:var(--fs-lg);font-weight:600}+.cleanupfieldset>.geist-fieldset-footer{border-top:1px solid var(--border-10);background:var(--overlay-5)}+.cleanupfieldset{display:flex;flex-direction:column;min-width:0;min-height:176px;margin:0;padding:0;overflow:hidden;border:1px solid var(--line-soft);border-radius:12px;background:var(--surface)}-.cleanupfieldset legend{margin-left:14px;padding:0 6px;color:var(--ink);font-size:var(--fs-lg);font-weight:600}.cleanupfieldset>.geist-fieldset-content{flex:1;min-height:0;padding:20px}.cleanupfieldset strong{display:block;margin-bottom:10px;font-size:var(--fs-xl)}.cleanupfieldset p{margin:0;color:var(--muted);font-size:var(--fs-sm);line-height:1.6}-.cleanupfieldset>.geist-fieldset-footer{box-sizing:border-box;min-height:56px;margin:0;padding:12px 12px 12px 20px;- display:flex;align-items:center;gap:8px;border-top:1px solid var(--border-10);background:var(--overlay-5)}.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:7px;cursor:pointer}.cleanupfieldset button:hover{border-color:var(--tungsten);color:var(--ink);background:var(--hover)}@@ -743,7 +752,9 @@ 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:24px}.resourcesyncbody h3{margin:0 0 8px;font-size:var(--fs-lg)}.resourcesyncbody p{max-width:760px;margin:0;color:var(--muted);font-size:var(--fs-sm);line-height:1.55}.resourcesyncfooter,.resourceapplyrow{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 16px;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));border-top:1px solid var(--line-soft);background:var(--overlay-5)}.resourcecache>div{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:baseline;gap:4px 16px;padding:16px}.resourcecache>div+div{border-left:1px solid var(--line-soft)}.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)}+.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:space-between;gap:16px;padding:0 16px;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}.tagbar.is-stuck,.count.is-stuck,.entitytagbar.is-stuck,.entitycollectionhead.is-stuck{background:color-mix(in srgb,#080A0D 84%,transparent);border-bottom-color:var(--line-soft);backdrop-filter:saturate(1.35) blur(16px);@@ -1471,28 +1482,32 @@ body.settings-open{overflow:hidden}vercel-geist-toast.md;量纲沿用本站实测 Geist 的那一套:8px 圆角、发丝边、比页面亮一档的表面。warn 态加一圈红边和图标,但失败的原因仍以页内持久行为准——toast 只负责提一句。 */-.toasts{position:fixed;right:16px;bottom:22px;z-index:var(--layer-popover);display:grid;gap:8px;+/* 行距用每条自己的上外边距,不用容器 gap:收起时高度和外边距一起过渡到 0,+ 栈才收得平顺;gap 是容器的,收不掉。 */+.toasts{position:fixed;right:16px;bottom:22px;z-index:var(--layer-popover);display:grid;justify-items:end;pointer-events:none}-.toast{pointer-events:auto;display:flex;align-items:flex-start;gap:9px;- width:min(440px,calc(100vw - 32px));padding:11px 10px 11px 13px;+.toast{pointer-events:auto;box-sizing:border-box;display:flex;align-items:center;gap:9px;+ width:min(440px,calc(100vw - 32px));margin-top:8px;padding:11px 10px 11px 13px;border:1px solid var(--line);border-radius:8px;background:var(--surface);color:var(--ink);font-size:var(--fs-sm);line-height:1.6;box-shadow:0 2px 4px #0003,0 24px 80px #000b;animation:toast-in .18s ease}@keyframes toast-in{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}.toast.warn{border-color:color-mix(in srgb,var(--drop) 38%,var(--line))}-.toast.warn>svg{width:15px;height:15px;flex:none;margin-top:3px;stroke:var(--drop);fill:none;+.toast.warn>svg{width:15px;height:15px;flex:none;stroke:var(--drop);fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.toast p{flex:1;margin:0;min-width:0}.toast b{font-variant-numeric:tabular-nums}/* 动作是具名的下一步(去看更新),文字按钮跟正文同行;关闭才是 24px 图标位。 */-.toast .tact{flex:none;align-self:center;border:0;background:none;padding:0;+.toast .tact{flex:none;border:0;background:none;padding:0;color:var(--tungsten);font:inherit;font-size:var(--fs-sm);cursor:pointer}.toast .tact:hover{color:var(--ink);text-decoration:none}+.toast .tact[aria-busy="true"]{color:var(--muted);cursor:default}.toast .tclose{flex:none;width:24px;height:24px;padding:0;border:0;border-radius:var(--control-radius);background:transparent;color:var(--muted);display:grid;place-items:center;cursor:pointer}.toast .tclose:hover{background:var(--hover);color:var(--ink)}.toast .tclose svg{width:13px;height:13px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round}-.toast.leaving{opacity:0;transform:translateY(4px);transition:opacity .15s ease,transform .15s ease}+.toast.leaving{height:0!important;margin-top:0;padding-block:0;border-block-width:0;opacity:0;overflow:hidden;+ transition:height .18s ease,margin .18s ease,padding .18s ease,border-width .18s ease,opacity .12s ease}.mixgrouplabel{display:flex;align-items:center;gap:8px;margin:12px 10px 6px;color:var(--ink);font-size:var(--fs-xs);font-weight:600}.mixgrouplabel:first-child{margin-top:4px}@@ -1717,7 +1732,7 @@ 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:230px}+ .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}@@ -2287,7 +2302,7 @@ details.fcred{display:block}*[data-middle-truncate]{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:clip}/* 链接管理沿用资源同步那套盒子,只加这里独有的两块:概览格和结果表。表格必须自己横向滚动——地址列很长,让它撑破 body 会把整页拖成横向可滚。 */-.linksummary{margin-top:18px}.linksummary .resourcecache{border:1px solid var(--line-soft);border-radius:10px;border-top:1px solid var(--line-soft)}+.linksummary .resourcecache{border-top:0;padding:0}.linksummary .resourcecache b{font-size:var(--fs-lg)}.linkgroup{padding:16px;border-top:1px solid var(--line-soft)}.linkgroup:first-child{border-top:0}.linkgroup h4{margin:0 0 4px;font-size:var(--fs-md);font-weight:600}diff --git a/web/app.js b/web/app.jsindex a2c4ec4ee..7822a0aae 100644--- a/web/app.js+++ b/web/app.js@@ -1,8 +1,8 @@import {$, ENTITY_ROUTES, LOC, ROUTE_ENTITIES, ROUTE_STATES, SITE_FAVICONS, STATE_LABELS, STATE_ROUTES, api, brandIcon, entityPath, esc, faviconFallbackUrl, faviconUrl, linkHost, linkMarkUrl, fmtClock, fmtDur, fmtSize, foldName, icon, isCatalogPath, pageTitle, realDuration} from './js/core.js';import { initMiddleTruncate } from './js/middle-truncate.js';import {- emptyStateHtml, loadingDotsHtml, mediaViewButtonsHtml, noteHtml, progressHtml, scrollerHtml,- setActionBusy, skeletonHtml, spinnerHtml, wireBusyActions, wireScrollers,+ emptyStateHtml, fieldsetHeader, loadingDotsHtml, mediaViewButtonsHtml, noteHtml, progressHtml,+ scrollerHtml, setActionBusy, skeletonHtml, spinnerHtml, wireBusyActions, wireScrollers,} from './js/ui-components.js';initMiddleTruncate(document);@@ -280,15 +280,27 @@ const toast=(html,{timeout=6000,warn=false,action=null}={})=>{const root=$('#toasts');const item=document.createElement('div');item.className='toast'+(warn?' warn':'');- item.innerHTML=`${warn?icon('alert'):''}<p>${html}</p>${- action?`<button class="tact">${esc(action.label)}</button>`:''- }<button class="tclose" title="关闭" aria-label="关闭提示">${icon('x')}</button>`;+ const paint=(body,alert)=>{+ item.classList.toggle('warn',!!alert);+ item.innerHTML=`${alert?icon('alert'):''}<p>${body}</p>${+ action&&!alert&&body===html?`<button class="tact">${esc(action.label)}</button>`:''+ }<button class="tclose" title="关闭" aria-label="关闭提示">${icon('x')}</button>`;+ item.querySelector('.tclose').onclick=close;+ const act=item.querySelector('.tact');+ if(act)act.onclick=()=>{setActionBusy(act);action.run()};+ };let timer=null;- const close=()=>{clearTimeout(timer);item.classList.add('leaving');- setTimeout(()=>item.remove(),160)};- item.querySelector('.tclose').onclick=close;- if(action)item.querySelector('.tact').onclick=()=>{close();action.run()};+ /* 收起前先把当前高度写死再过渡到 0。直接 remove() 会让这一格瞬间消失,+ 栈里剩下的 toast 一次跳过来,正是撤销那一下最明显的抖动。 */+ const close=()=>{clearTimeout(timer);+ item.style.height=`${item.offsetHeight}px`;item.getBoundingClientRect();+ item.classList.add('leaving');setTimeout(()=>item.remove(),200)};const arm=()=>{if(timeout)timer=setTimeout(close,timeout)};+ /* 结果就写在同一条 toast 上,不再另发一条。原先是「关掉回执 + 弹出已撤销」,+ 两条在同一个底部对齐的栈里一进一出,看上去就是整块跳了一下。 */+ item.replaceMessage=(body,{warn:alert=false,timeout:next=4000}={})=>{+ clearTimeout(timer);paint(body,alert);timeout=next;arm()};+ paint(html,warn);item.addEventListener('mouseenter',()=>clearTimeout(timer));item.addEventListener('mouseleave',arm);root.prepend(item);arm();@@ -299,13 +311,17 @@ const toast=(html,{timeout=6000,warn=false,action=null}={})=>{/* 所有可逆写操作共用同一种回执:只在请求真正完成后报过去时结果,撤销入口保留 8 秒。撤销本身也是一次真实写入,失败时另报一条短错误,不能把本地 UI偷偷改回去假装成功。不可逆或不适合撤销的操作仍用同一函数,但不传 undo。 */-const actionReceipt=(message,{undo=null,timeout=undo?8000:6000}={})=>toast(esc(message),{- timeout,- action:undo?{label:'撤销',run:async()=>{- try{await undo();toast('已撤销')}- catch(error){toast(`撤销失败:${esc(error.message||'请重试')}`,{warn:true})}- }}:null,-});+const actionReceipt=(message,{undo=null,timeout=undo?8000:6000}={})=>{+ let item=null;+ item=toast(esc(message),{+ timeout,+ action:undo?{label:'撤销',run:async()=>{+ try{await undo();item.replaceMessage('已撤销')}+ catch(error){item.replaceMessage(`撤销失败:${esc(error.message||'请重试')}`,{warn:true})}+ }}:null,+ });+ return item;+};const actionFailure=(message,error)=>toast(`${esc(message)}失败:${esc(error?.message||'请重试')}`,{warn:true});@@ -1823,7 +1839,7 @@ function enterManagementSurface(){$('#tiers').style.display='none';$('#tagbar').style.display='none';document.body.classList.remove('entity-open','index-open');}-async function openStats(push=true,focusResource=false){+async function openStats(push=true){releaseHoverPreviews();if(push)route('/stats');const surface=claimSurface('/stats');@@ -1877,22 +1893,22 @@ async function openStats(push=true,focusResource=false){<section class="insightdetail"><div id="stats-detail-inventory" role="tabpanel" data-stats-detail="inventory" class="insightdetailbody"><div class="insightcopy"><span>库存</span><h2>${totalVideos.toLocaleString()}</h2><b>个视频</b>- <p>按真实挂载位置汇总;体积和视频数使用同一份 ledger 快照。</p></div>+ </div><div class="insightvisual">${locationRows}</div></div><div id="stats-detail-viewing" role="tabpanel" data-stats-detail="viewing" class="insightdetailbody" hidden><div class="insightcopy"><span>观看</span><h2>${cs.played.toLocaleString()}</h2><b>个作品有播放记录</b>- <p>累计 ${hrs(cs.play_seconds)};馆藏播放与关注页直接在线播放都计入,不要求先保存。</p></div>+ <p>累计 ${hrs(cs.play_seconds)}</p></div><div class="insightfacts">${kv('馆藏观看',cs.library_played.toLocaleString())}${kv('在线直接观看',cs.online_played.toLocaleString())}${kv('高潮计数',cs.o_total.toLocaleString())}${kv('快进扫过',cs.skimmed.toLocaleString())}${kv('明确不喜欢',cs.dislike.toLocaleString())}${kv('看过了',cs.seen.toLocaleString())}${kv('回收站',cs.trash.toLocaleString())}</div></div><div id="stats-detail-coverage" role="tabpanel" data-stats-detail="coverage" class="insightdetailbody" hidden><div class="insightcopy"><span>内容标签覆盖</span><h2>${coverage}%</h2><b>${d.tag_cov.toLocaleString()} / ${a.videos.toLocaleString()}</b>- <p>归属与加工分别保留真实分母,不用装饰性进度替代缺失数据。</p></div>+ </div><div class="insightvisual">${metric('有创作者',a.creator,a.videos)}${metric('有番号',a.code,a.videos)}${metric('有厂牌',a.studio,a.videos)}${metric('已抽帧',a.thumb,a.videos)}${metric('已探测时长',a.duration,a.videos)}</div></div><div id="stats-detail-storage" role="tabpanel" data-stats-detail="storage" class="insightdetailbody" hidden><div class="insightcopy"><span>使用空间</span><h2>${storage.measured}</h2><b>个卷已取得容量</b>- <p>同时统计系统盘、资源盘、115 与 PikPak;离线或未映射的来源明确保留,不伪造为 0。</p></div>+ </div><div class="insightvisual insightstorage">${storageTable}</div></div></section><section class="insightpanel">@@ -1905,8 +1921,6 @@ async function openStats(push=true,focusResource=false){<div id="stats-panel-recent" role="tabpanel" data-stats-panel="recent" hidden>${recentTable}</div><div id="stats-panel-sources" role="tabpanel" data-stats-panel="sources" hidden>${sourceTable}</div></div></section>- ${linkManagerMarkup()}- ${resourceSyncMarkup()}</div>`;const statsRoot=$('#stats');statsRoot.querySelectorAll('[data-stats-metric]').forEach(button=>button.onclick=()=>{@@ -1921,10 +1935,7 @@ async function openStats(push=true,focusResource=false){});$('#stats').querySelectorAll('[data-k]').forEach(b=>b.onclick=()=>{closeStats(); toggleTag(b.dataset.k)});- await wireLinkManager();- await wireResourceSync();- if(focusResource)$('#resource-sync')?.scrollIntoView({block:'start'});- else window.scrollTo({top:0,behavior:'smooth'});+ window.scrollTo({top:0,behavior:'smooth'});}function showHomeSurfaces(){// 两个类都要清:只清 entity-open 会让从索引页回首页时顶栏一直空着,@@ -1942,17 +1953,16 @@ function closeStats(push=true){if(push)route('/');showHomeSurfaces();load(true)}function linkManagerMarkup(){return `<section class="resourcesync" id="link-manager" aria-labelledby="linkManagerTitle"><h2 id="linkManagerTitle">链接管理</h2>- <div class="resourcesyncbox"><div class="resourcesyncbody"><h3>外链与实体</h3>- <p>资料页上的官网、事务所与社媒链接。逐条访问一遍,找出已经打不开的。</p>- <div id="linkSummary" class="linksummary"></div></div>- <div class="resourcesyncfooter"><p>检查只联网、不改账本;七百多条约需几分钟。</p>+ <div class="resourcesyncbox" data-geist-fieldset>${fieldsetHeader('linkBoxTitle','外链与实体')}+ <div class="resourcesyncbody geist-fieldset-content"><div id="linkSummary" class="linksummary"></div></div>+ <div class="resourcesyncfooter geist-fieldset-footer" data-geist-fieldset-footer><button class="resourceaction" type="button" id="linkCheck">${icon('refresh-cw')}<span>检查死链</span></button></div></div><div id="linkCheckResult" aria-live="polite"></div></section>`;}async function wireLinkManager(){const button=$('#linkCheck'),result=$('#linkCheckResult'),summary=$('#linkSummary');if(!button||!result)return;- const active=()=>location.pathname==='/stats'&&!$('#stats').hidden&&document.body.contains(result);+ const active=()=>location.pathname==='/data-cleanup'&&!$('#stats').hidden&&document.body.contains(result);const KINDS={official:'官网 · 事务所',social:'社媒',catalog:'资料库',source_reference:'来源记录'};try{const info=await api('/api/links');@@ -2011,16 +2021,16 @@ async function wireLinkManager(){function resourceSyncMarkup(){return `<section class="resourcesync" id="resource-sync" aria-labelledby="resourceSyncTitle"><h2 id="resourceSyncTitle">资源同步</h2>- <div class="resourcesyncbox"><div class="resourcesyncbody"><h3>网盘与账本</h3>- <p>核对已挂载网盘与账本。网盘上已删除的条目先进入回收站;只清理没有在用的预览与播放缓存。</p></div>- <div class="resourcesyncfooter"><p>离线来源会整库跳过。候选 CSV、来源证据、女优头像和厂牌 Logo 不会删除。</p>+ <div class="resourcesyncbox" data-geist-fieldset>${fieldsetHeader('resourceBoxTitle','网盘与账本')}+ <div class="resourcesyncbody geist-fieldset-content"><p>网盘上已删除的条目进入回收站;只清理没有在用的预览与播放缓存。</p></div>+ <div class="resourcesyncfooter geist-fieldset-footer" data-geist-fieldset-footer><button class="resourceaction" type="button" id="resourceScan">${icon('refresh-cw')}<span>扫描差异</span></button></div></div><div id="resourceSyncResult" aria-live="polite"></div></section>`;}async function wireResourceSync(){const scan=$('#resourceScan'),result=$('#resourceSyncResult');if(!scan||!result)return;- const active=()=>location.pathname==='/stats'&&!$('#stats').hidden&&document.body.contains(result);+ const active=()=>location.pathname==='/data-cleanup'&&!$('#stats').hidden&&document.body.contains(result);const setBusy=(busy,done=false)=>{setActionBusy(scan,busy);scan.innerHTML=`${icon('refresh-cw')}<span>${busy?'扫描中':done?'重新扫描':'扫描差异'}</span>`;@@ -2034,8 +2044,8 @@ async function wireResourceSync(){<strong>${source.online?source.missing.toLocaleString():'—'}</strong><small>${source.online?`项已从网盘删除 · 已核对 ${source.checked.toLocaleString()} 项${source.unreadable?` · ${source.unreadable.toLocaleString()} 项暂时无法读取`:''}`:`账本有 ${source.total.toLocaleString()} 项`}</small></article>`).join('')}</div><div class="resourcecache"><div><span>孤立缓存</span><b>${cache.files.toLocaleString()}</b><small>${fmtSize(cache.bytes||0)}</small></div>- <div><span>待同步</span><b>${Number(payload.missing||0).toLocaleString()}</b><small>项;应用后进入回收站</small></div></div>- <div class="resourceapplyrow">${hasChanges?`<p>确认后才会更改账本;操作可从回收站恢复。</p><button class="resourceaction resourcedanger" type="button" id="resourceApply">同步并清理</button>`:+ <div><span>待同步</span><b>${Number(payload.missing||0).toLocaleString()} 项</b></div></div>+ <div class="resourceapplyrow">${hasChanges?`<button class="resourceaction resourcedanger" type="button" id="resourceApply">同步并清理</button>`:'<p class="resourcesyncok">账本与已挂载来源一致,没有孤立缓存。</p>'}</div></div>`;$('#resourceApply')?.addEventListener('click',async event=>{const button=event.currentTarget;@@ -2072,13 +2082,16 @@ async function wireResourceSync(){scan.onclick=()=>followScan(null);try{const existing=await api('/api/resource-sync/scan',{method:'POST',body:JSON.stringify({background:true,status_only:true})});- if(existing.status!=='idle')void followScan(existing);+ /* 只跟进还在跑的那次。上一轮的完成结果是那一刻的快照,进页面就铺开会被当成+ 现在的账本状态——数字早就不准了,而页面上没有任何东西说它是旧的。 */+ if(existing.status==='running')void followScan(existing);}catch(_error){}}+/* 旧直达 URL 仍然可用,落点跟着面板一起搬到数据管理。 */async function openResourceSync(push=true){- if(push)route('/stats#resource-sync');- else if(location.pathname==='/resource-sync')route('/stats#resource-sync',true);- await openStats(false,true);+ if(push||location.pathname==='/resource-sync')route('/data-cleanup#resource-sync',!push);+ await openDataCleanup(false);+ $('#resource-sync')?.scrollIntoView({block:'start'});}/* 口味仪表按窗口持久缓存:刷新页面也先显示上次结果。24 小时内不重读;@@ -2127,7 +2140,7 @@ function openTasteSignal(kind,name){}function renderTaste(d){const s=d.summary||{},coverage=d.coverage||{},rank=d.rankings||{},storage=d.storage||{};- const summary=(label,value,sub)=>`<div class="tastesummary"><span>${label}</span><b>${value}</b><small>${sub}</small></div>`;+ const summary=(label,value,sub='')=>`<div class="tastesummary"><span>${label}</span><b>${value}</b>${sub?`<small>${sub}</small>`:''}</div>`;const coverageMetric=(label,value,sub,done,total)=>`<div class="tastecovermetric"><span>${label}</span><b>${value}</b><small>${sub}</small>${progressHtml(`${label}:${done} / ${total}`,done,total)}</div>`;const sourceRows=(d.sources||[]).map(source=>`<div class="tastesource"><span class="tastebrowser">${icon(source.browser==='browserexport'?'upload':'database')}</span>@@ -2158,21 +2171,20 @@ function renderTaste(d){<div class="tastesummaries" data-taste-summary="browser"${tasteEvidence==='browser'?'':' hidden'}>${summary('浏览记录',Number(s.history_visits||0).toLocaleString(),`${s.history_sources||0} 个数据源 · ${tasteDate(s.range_start)}—${tasteDate(s.range_end)}`)}${summary('口味维度',categoryRows.length.toLocaleString(),categoryRows[0]?.name||'尚无主维度')}- ${summary('浏览候选',gapRows.length.toLocaleString(),'只作待复核证据')}+ ${summary('浏览候选',gapRows.length.toLocaleString())}${summary('私有导出',Number(storage.exports||0).toLocaleString(),fmtSize(storage.bytes||0))}</div><div class="tastesummaries" data-taste-summary="peach"${tasteEvidence==='peach'?'':' hidden'}>${summary('Peach 看过',Number(s.peach_items||0).toLocaleString(),tasteHours(s.peach_seconds||0))}- ${summary('喜欢',Number(s.liked||0).toLocaleString(),'明确正向反馈')}- ${summary('不合口味',Number(s.disliked||0).toLocaleString(),'只归于具体项目')}- ${summary('有标签',Number(coverage.tagged||0).toLocaleString(),`${coverage.untagged||0} 项待补`)}</div>+ ${summary('喜欢',Number(s.liked||0).toLocaleString())}+ ${summary('不合口味',Number(s.disliked||0).toLocaleString())}+ ${summary('有标签',Number(coverage.tagged||0).toLocaleString())}</div><section class="tastehero" data-taste-evidence-panel="browser"${tasteEvidence==='browser'?'':' hidden'}><div class="insightcopy"><span>浏览器画像</span><h2>${Number(s.history_visits||0).toLocaleString()}</h2><b>条聚合访问证据</b>- <p>浏览器记录是当前分析主体;页面只展示聚合结果,不展示原始 URL、标题或搜索内容。</p><small>${d.updated_at?`更新于 ${tasteDate(d.updated_at)}`:'尚未采集浏览记录'}</small></div><div class="tastebars">${categoryBars}</div></section><section class="tastehero" data-taste-evidence-panel="peach"${tasteEvidence==='peach'?'':' hidden'}><div class="insightcopy"><span>Peach 观看</span><h2>${Number(s.peach_items||0).toLocaleString()}</h2><b>个作品有内部行为证据</b>- <p>播放、评分与明确反馈保持独立,不反向代表全部浏览口味。</p></div>+ </div><div class="insightvisual">${coverageMetric('有标签',Number(coverage.tagged||0).toLocaleString(),`${coverage.untagged||0} 项待补`,coverage.tagged||0,(coverage.tagged||0)+(coverage.untagged||0))}${coverageMetric('有身份',Number(coverage.identified||0).toLocaleString(),`${coverage.unidentified||0} 项待补`,coverage.identified||0,(coverage.identified||0)+(coverage.unidentified||0))}@@ -2192,10 +2204,8 @@ function renderTaste(d){${rankPanel('peach','creators',rank.peach_creators||[],'creator','暂无创作者证据','creator')}${rankPanel('peach','performers',rank.peach_performers||rank.performers||[],'performer','暂无女优证据','performer')}</div></section>- <div data-taste-evidence-panel="peach"${tasteEvidence==='peach'?'':' hidden'}>${noteHtml('“不合口味”只记录到具体项目与理由,不自动给标签降权。',{className:'tastefootnote tastenegative'})}</div>- <section class="insightpanel tastesources"><header><div><h3>数据源</h3><p>支持 macOS / Windows 的 Zen、Safari、Firefox、Chrome;这里列出已经采集的设备。</p></div></header>+ <section class="insightpanel tastesources"><header><div><h3>数据源</h3></div></header><div class="insightpanelbody"><div>${sourceRows||emptyStateHtml('database','还没有数据源','导入或读取浏览记录后,这里会列出已采集设备。')}</div></div></section>- ${noteHtml('原始 URL、标题与搜索内容不会显示在页面,也不会写入 ledger;所有画像均为候选。',{className:'tastefootnote tasteprivacy'})}</div>`;const root=$('#stats'),stateEl=root.querySelector('[data-taste-state]'),file=root.querySelector('[data-taste-file]');root.querySelector('[data-taste-window]').value=d.window||tasteWindow;@@ -2346,33 +2356,45 @@ 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:`<div class="cleanuploading">${loadingDotsHtml('正在读取数据管理状态…')}</div>`});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('垃圾文件、重复文件和空文件夹集中处理');+ 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('');$('#stats').innerHTML=`<div class="cleanupgrid">- <fieldset class="cleanupfieldset" data-geist-fieldset><legend>垃圾文件</legend>- <div class="geist-fieldset-content"><strong>${Number(junk.pending_total||0).toLocaleString()} 个待判断</strong>- <p>查看推广文件、网址快捷方式和其它物理资源候选;确认后先进入回收站。</p></div>+ <section class="cleanupfieldset" data-geist-fieldset aria-labelledby="cleanupJunkTitle">+ ${fieldsetHeader('cleanupJunkTitle','垃圾文件')}+ <div class="geist-fieldset-content"><strong>${Number(junk.pending_total||0).toLocaleString()} 个待判断</strong></div><footer class="geist-fieldset-footer" data-geist-fieldset-footer><button type="button" data-cleanup-open="junk">查看垃圾文件</button></footer>- </fieldset>- <fieldset class="cleanupfieldset" data-geist-fieldset><legend>重复文件</legend>- <div class="geist-fieldset-content"><strong>${Number(duplicates.total||0).toLocaleString()} 组 · ${Number(duplicates.files||0).toLocaleString()} 个文件</strong>- <p>按番号、分卷与时长证据分组;批量操作仍只把文件移入回收站。</p></div>+ </section>+ <section class="cleanupfieldset" data-geist-fieldset aria-labelledby="cleanupDupTitle">+ ${fieldsetHeader('cleanupDupTitle','重复文件')}+ <div class="geist-fieldset-content"><strong>${Number(duplicates.total||0).toLocaleString()} 组 · ${Number(duplicates.files||0).toLocaleString()} 个文件</strong></div><footer class="geist-fieldset-footer" data-geist-fieldset-footer><button type="button" data-cleanup-open="duplicates">查看重复文件</button></footer>- </fieldset>- <fieldset class="cleanupfieldset cleanupemptyfolders" data-geist-fieldset><legend>空文件夹</legend>- <div class="geist-fieldset-content"><p>从已挂载的资源根开始自底向上删除空目录;来源根本身不会删除。</p>+ </section>+ <section class="cleanupfieldset cleanupemptyfolders" data-geist-fieldset aria-labelledby="cleanupEmptyTitle">+ ${fieldsetHeader('cleanupEmptyTitle','空文件夹')}+ <div class="geist-fieldset-content"><p>不会删除来源根目录。</p><div class="cleanupsources">${sourceState}</div><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>- </fieldset>- </div>`;+ </section>+ ${DATA_MANAGEMENT_ENTRIES.map(([section,title,label])=>`+ <section class="cleanupfieldset" data-geist-fieldset aria-labelledby="cleanup-${section}-title">+ ${fieldsetHeader(`cleanup-${section}-title`,title)}+ <div class="geist-fieldset-content"><strong data-cleanup-count="${section}">—</strong></div>+ <footer class="geist-fieldset-footer" data-geist-fieldset-footer><button type="button" data-cleanup-go="${section}">${esc(label)}</button></footer>+ </section>`).join('')}+ </div>+ ${linkManagerMarkup()}+ ${resourceSyncMarkup()}`;$('#stats').querySelector('[data-cleanup-open="junk"]').onclick=()=>openManage('ads');$('#stats').querySelector('[data-cleanup-open="duplicates"]').onclick=()=>openDuplicates();+ $('#stats').querySelectorAll('[data-cleanup-go]').forEach(button=>+ button.onclick=()=>openManage(button.dataset.cleanupGo));+ paintDataManagementCounts();const emptyButton=$('#stats').querySelector('[data-cleanup-empty]');emptyButton.onclick=async()=>{if(!confirm('删除所有已挂载资源来源中的空文件夹?来源根目录不会删除。'))return;@@ -2387,6 +2409,38 @@ async function openDataCleanup(push=true){}catch(error){status.textContent=error.message||'空文件夹清理失败';actionFailure('空文件夹清理',error)}finally{setActionBusy(emptyButton,false);emptyButton.innerHTML=original}};+ await wireLinkManager();+ await wireResourceSync();+}++/* 数据管理是「库里已经有的东西怎么收拾」的唯一入口:广告、重复、空目录,+ 加上复核队列、回收站和高清版。它们此前散在管理菜单和统计页两处,+ 统计页因此还挂着两块跟统计无关的面板。 */+const DATA_MANAGEMENT_ENTRIES=[+ ['review','人工复核','查看候选'],+ ['trash','回收站','查看回收站'],+ ['quality','高清版','查看高清版'],+];+/* 计数各自失败各自算:复核接口出错不该把回收站那张卡也变成「—」。 */+async function paintDataManagementCounts(){+ const write=(section,text)=>{+ const el=$('#stats')?.querySelector(`[data-cleanup-count="${section}"]`);+ if(el)el.textContent=text;+ };+ const fill=async(section,load)=>{+ try{write(section,await load())}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()} 条待复核`;+ }),+ 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()} 个待升级`),+ ]);}let dupData=null;@@ -4868,20 +4922,22 @@ const EDGE_ICONS=[['immerse','沉浸模式','play'],['manage','管理','database'],];-/* 统计、数据清理、回收站、人工复核默认都收在「管理」下,不主动占用顶层空间;- 用户仍可在设置里把某个具体页面加到顶层。每个页面都有可直接打开的 URL。- 顺序按做事顺序分成两段:先是库里已有的东西——看现状、复核新进来的候选、- 清广告与重复、落到回收站;再是要往外拿的——关注和高清版都是「还想要什么」,- 原先把它夹在高清版和回收站中间,两边都不挨着。 */+/* 每个管理页的身份(标题、图标、可直达的 URL)。用户仍可在设置里把其中任何+ 一个加到顶层侧栏,所以这里保留全部页面,不因为它进了数据管理就删掉。 */const MANAGE_SECTIONS=[['stats','统计','chart'],['taste','口味','heart'],['review','人工复核','square-check-big'],- ['cleanup','数据清理','hard-drive'],+ ['cleanup','数据管理','hard-drive'],['trash','回收站','trash'],['follow','关注','rss'],['quality','高清版','sparkles'],];+/* 管理菜单只留四项。人工复核、回收站、高清版都是「收拾库里已有的东西」,+ 和垃圾文件、重复文件、空文件夹是同一件事的不同步骤,统一从数据管理进;+ 统计页也因此不再挂链接管理和资源同步这两块跟统计无关的面板。 */+const MANAGE_MENU_SECTIONS=['stats','taste','cleanup','follow'];+const manageMenuSections=()=>MANAGE_SECTIONS.filter(([key])=>MANAGE_MENU_SECTIONS.includes(key));const OPTIONAL_EDGE_ICONS=MANAGE_SECTIONS.map(([key,label,ic])=>key==='follow'?['follow-manage','关注管理',ic]:key==='cleanup'?['data-cleanup',label,ic]:[key,label,ic]);@@ -5060,7 +5116,7 @@ function buildManageBar(){bar.classList.remove('is-open');bar.innerHTML=`<button class="managebar-toggle" type="button" aria-expanded="false" aria-controls="managebar-menu"><span class="managebar-current">${icon(entry[2])}<span>管理 · ${entry[1]}</span></span>${icon('chevron-down')}- </button><div class="managebar-menu" id="managebar-menu">${MANAGE_SECTIONS.map(([k,label,ic])=>+ </button><div class="managebar-menu" id="managebar-menu">${manageMenuSections().map(([k,label,ic])=>`<button data-manage="${k}" aria-pressed="${k===current}">${icon(ic)}<span>${label}</span></button>`).join('')}</div>`;const toggle=bar.querySelector('.managebar-toggle');toggle.onclick=()=>{const open=bar.classList.toggle('is-open');toggle.setAttribute('aria-expanded',String(open))};@@ -5093,7 +5149,7 @@ function openManage(section='stats'){if(section==='taste'){openTaste();return}if(section==='review'){openReview();return}if(section==='cleanup'){openDataCleanup();return}- // 旧直达 URL 继续保留;它们共享同一个「数据清理」导航身份。+ // 旧直达 URL 继续保留;它们共享同一个「数据管理」导航身份。if(section==='dupes'){openDuplicates();return}if(section==='quality'){openQualityGoals();return}if(section==='follow'){openFollowManage();return}@@ -5530,13 +5586,22 @@ async function openPlaylist(playlistId,itemId=null,push=true){if(push)route(`/playlists/${playlistId}/${chosen}`);api('/api/playlist',{method:'POST',body:JSON.stringify({action:'progress',id:playlistId,asset_id:chosen})}).catch(()=>{});}+/* 关掉详情要不要重新装一遍列表,判据是「退回去有没有东西可看」。+ 按 `#grid` 有没有子节点判会误判:直接打开 `/parts/28125/28125` 这类深链时,+ 网格里躺着一个还没被替换掉的加载骨架,它也是子节点。于是关掉播放器后+ `route('/')` 只改了地址,列表永远停在那张骨架上——首页看起来打不开了。+ 卡片一定带 `data-id`(Mix 带 `data-mix-seed`),骨架没有。 */+function hasReturnSurface(){+ return !!$('#grid').querySelector('[data-id],[data-mix-seed]')+ ||!$('#index').hidden||!$('#stats').hidden;+}async function openItem(id,push=true,queueContext=null,anchor=null){releaseHoverPreviews();const origin=anchor?.isConnected?anchor:(detailOriginAnchor?.isConnected?detailOriginAnchor:null);const above=anchor?.isConnected? anchor.getBoundingClientRect().top+anchor.getBoundingClientRect().height/2>window.innerHeight/2: detailOriginAbove;- const returnSurfaceReady=$('#grid').children.length>0||!$('#index').hidden||!$('#stats').hidden;+ const returnSurfaceReady=hasReturnSurface();const needsReturnRestore=detailReturnNeedsRestore||(!push&&!returnSurfaceReady);const returnBars=barsContext.type==='item'?detailReturnBarsContext:cloneBarsContext(barsContext);if(push)detailReturnPath=location.pathname+location.search;diff --git a/web/js/core.js b/web/js/core.jsindex 80d9c76c1..2cffa0344 100644--- a/web/js/core.js+++ b/web/js/core.js@@ -18,10 +18,10 @@ const api=async(p,o)=>{};const pageTitle=path=>{const url=new URL(path,location.origin),parts=decodeURIComponent(url.pathname).split('/').filter(Boolean);- const fixed={stats:'统计',taste:'口味',review:'人工复核','data-cleanup':'数据清理',duplicates:'重复文件','quality-goals':'高清版',+ const fixed={stats:'统计',taste:'口味',review:'人工复核','data-cleanup':'数据管理',duplicates:'重复文件','quality-goals':'高清版',follow:'关注','follow-manage':'关注管理',playlists:'播放列表',performers:'女优',studios:'厂牌',creators:'创作者',series:'系列',tags:'标签',unseen:'没看过','watch-later':'稍后看',flagged:'已标记',- immerse:'沉浸模式',mix:'Mix',item:'作品','resource-sync':'统计','junk-files':'垃圾文件'};+ immerse:'沉浸模式',mix:'Mix',item:'作品','resource-sync':'数据管理','junk-files':'垃圾文件'};const label=parts.length>1&&['performers','studios','creators','series'].includes(parts[0])? parts.slice(1).join('/') : fixed[parts[0]];return label?`${label} · Peach`:'Peach · 蜜桃';diff --git a/web/js/ui-components.js b/web/js/ui-components.jsindex 0d15e67b5..91ace6293 100644--- a/web/js/ui-components.js+++ b/web/js/ui-components.js@@ -11,6 +11,18 @@ export function noteHtml(message,{variant='secondary',label='',className=''}={})${icon(symbol)}<p>${label?`<b>${esc(label)}</b>`:''}<span>${esc(message)}</span></p></div>`;}+/**+ * Geist Fieldset 的标题条。标题放在框体里,不用原生 `<legend>`。+ *+ * `<legend>` 会在上边框上开一个缺口,标题看起来骑在线上而不是在框里;三张卡的+ * 内容高度不同时,那道缺口的位置也跟着不齐。改成框内固定 52px 的横条后,+ * 标题条、内容区、底部操作条三段在同一行网格上对齐。+ */+export function fieldsetHeader(id,title){+ return `<header class="geist-fieldset-header" data-geist-fieldset-header>+ <h3 id="${esc(id)}">${esc(title)}</h3></header>`;+}+/** Determinate progress only. Callers supply real units instead of a decorative width. */export function progressHtml(label,value,max=100){const ceiling=Math.max(0,Number(max)||0);