Peach: Local-first video metadata scraper and media manager.
fix(onboarding): 让安装教程跨页面常驻
longmeidaoe5db150a4c7b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 18b42d73e..d52da9fab 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -23,7 +23,7 @@ Removed / Fixed / Security。### 修复-- **界面**:完成首次设置后,第一次进入首页会在右下角显示安装教程;六项任务按真实状态自动打勾,也可逐项跳过,全部处理后自动消失。+- **界面**:完成首次设置后,右下角会跨页面无闪烁地显示安装教程;六项任务按真实状态自动打勾,也可逐项跳过,全部处理后自动消失。## [0.34.1] - 2026-09-20diff --git a/docs/BOARD_UI.md b/docs/BOARD_UI.mdindex 65c71a401..4e91ceca9 100644--- a/docs/BOARD_UI.md+++ b/docs/BOARD_UI.md@@ -340,18 +340,19 @@ Board Switch medium:42×24px 轨道、18px 滑块,关闭时密码输入区辅助说明统一为 12/18、弱文字色。「浏览器历史记录」是「完成设置后」的二级标题,用14/20、500,不与一级分类争夺层级。-## 安装后首页教程+## 安装后教程首次设置表单只负责收集配置。提交成功后,普通入口带 `?onboarding=1` 进入首页;选择历史-导入时先去口味页,但同一浏览器会保留待办标记,回首页再显示。首页教程采用 BoardUI+导入时先去口味页,但同一浏览器会保留待办标记。教程采用 BoardUINotificationViewport 的右下角固定位置、400px 宽度、16px 卡片圆角、边框与下拉阴影;内部采用Announcement 的图标标题动作结构和 RareUI Task List 的 24px 圆形状态位、完成划线淡出与完成项后移。专用状态接口汇总馆藏、采集来源凭证、浏览器历史、关注来源、对应关注凭证和复核队列,不允许手动勾选;每项可单独跳过,并提供短时撤销。浮窗可折叠为只保留标题、完成进度和展开键;-全部任务完成或跳过后自动消失,不再要求一次额外确认;+在 Peach 的每个页面持续显示,全部任务完成或跳过后自动消失,不再要求一次额外确认;+切换页面时保留现有浮窗并静默刷新任务状态,状态未变化时不重建卡片;任务链接与「跳过」各自拥有独立悬停区;链接悬停时即时切换背景并隐藏上下两条内收直线分隔,不做跨行淡变,分隔线使用暗色主题下仍可辨识的按钮边框色,右侧箭头使用次级文字色。固定 revision、SHA 与差异见-[安装后首页教程取证](reference-snapshots/rareui-boardui-post-setup-tutorial.md)。+[安装后教程取证](reference-snapshots/rareui-boardui-post-setup-tutorial.md)。纠正(2026-09-12):这一段此处一度记过「上游 primary 没有悬停态」,同日取到规则原文后作废。当时那三条证据全落在同一个盲点上——悬停那一层挂在伪元素上。① 读 `className` 看不到:悬停diff --git a/docs/OPERATIONS.md b/docs/OPERATIONS.mdindex c300082d4..c4bce089c 100644--- a/docs/OPERATIONS.md+++ b/docs/OPERATIONS.md@@ -68,8 +68,8 @@ Peach 这一侧的行为:首启页与配置页按本机系统检测 CloudDrive默认 8900> --no-mdns --no-ledger-sync`,然后把浏览器打开到 `http://127.0.0.1:<端口>/`。这条服务没有 TLS、口令强制置空(安全边界就是那个绑定地址),首页是首次运行表单,提交端点是 `POST /setup`:应用已配置回 404、非回环调用方回 403、设置文件已存在回 409。- 成功页的普通入口带 `/?onboarding=1`,第一次进入正常首页时在右下角浮窗显示安装教程;选择浏览器历史- 导入则先去 `/taste?onboarding=1`。待办标记只存在当前浏览器,教程通过专用状态接口读取馆藏、+ 成功页的普通入口带 `/?onboarding=1`,进入 Peach 后在右下角浮窗显示安装教程;选择浏览器历史+ 导入则先去 `/taste?onboarding=1`。待办标记只存在当前浏览器,教程在不同页面间持续显示,并通过专用状态接口读取馆藏、采集凭证、浏览器历史、关注、关注凭证和复核的实际状态;单项可跳过并短时撤销,全部完成或跳过后教程自动消失。- 切换由 `tray.SetupGate` 做,Windows 托盘与 macOS 菜单栏共用。它挂在健康轮询里(Windows 10 秒、diff --git a/docs/reference-snapshots/rareui-boardui-post-setup-tutorial.md b/docs/reference-snapshots/rareui-boardui-post-setup-tutorial.mdindex ed1630079..e648128e9 100644--- a/docs/reference-snapshots/rareui-boardui-post-setup-tutorial.md+++ b/docs/reference-snapshots/rareui-boardui-post-setup-tutorial.md@@ -1,4 +1,4 @@-# 安装后首页教程取证+# 安装后教程取证最后复核:2026-09-20。@@ -15,10 +15,11 @@## Peach 采用方式-- 教程不放在首次设置表单;`POST /setup` 成功后用 `?onboarding=1` 标记一次安装后流程,第一次进入首页才显示。-- 任务不是可手动勾选的待办。首页读取馆藏、采集来源凭证、浏览器历史、关注来源、对应关注凭证和复核队列的实际状态,达到条件后自动打勾并移到清单末尾。+- 教程不放在首次设置表单;`POST /setup` 成功后用 `?onboarding=1` 标记一次安装后流程,进入 Peach 后显示。+- 任务不是可手动勾选的待办。教程读取馆藏、采集来源凭证、浏览器历史、关注来源、对应关注凭证和复核队列的实际状态,达到条件后自动打勾并移到清单末尾。- 下一步按钮始终指向第一项未完成任务;每项可跳过并短时撤销,全部完成或跳过后教程自动消失。-- 教程挂在 `main` 之外的右下角固定浮窗,不参与首页正文排版;离开首页即隐藏。历史导入可先进入 `/taste?onboarding=1`,待用户回到首页时继续教程。+- 教程挂在 `main` 之外的右下角固定浮窗,不参与当前页面正文排版;未处理完时跨页面持续显示。历史导入可先进入 `/taste?onboarding=1`,教程仍会保留。+- 切换页面时保留现有浮窗并静默刷新;任务状态没有变化时不重建卡片,避免浮窗闪烁。- 浮窗按内容增长并受视口高度限制,任务区单独滚动;可折叠为标题与完成进度,全部处理后自动消失。任务链接与「跳过」各有独立悬停区;链接悬停时背景即时切换、上下两条内收直线分隔同时隐去,不做跨行淡变;暗色主题仍保留可辨识的线条,右箭头保持次级文字色。## 明确差异diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex 514fa759a..be1475e64 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -134,7 +134,7 @@ class StylesheetPartitionTests(unittest.TestCase):class WebUiSourceTests(unittest.TestCase):- def test_post_setup_tutorial_lives_on_home_and_checks_real_state(self):+ def test_post_setup_tutorial_persists_across_routes_and_checks_real_state(self):root = Path(__file__).resolve().parents[1]html = (root / "web/index.html").read_text(encoding="utf-8")app = (root / "web/app.js").read_text(encoding="utf-8")@@ -149,13 +149,22 @@ class WebUiSourceTests(unittest.TestCase):self.assertIn("source=>source.accepts_cookie", app)self.assertIn("source=>source.cookie_saved", app)self.assertIn("taste.summary?.history_sources", app)- self.assertIn("location.pathname!=='/'", app)+ tutorial = app[app.index("const POST_SETUP_TUTORIAL_KEY="):app.index("const ENTITY_FILTER_KEYS=")]+ self.assertNotIn("location.pathname!=='/'", tutorial)+ self.assertIn("${icon('compass')}</span>", tutorial)+ self.assertIn("void syncPostSetupTutorial()", app[app.index("const route="):app.index("/* ── 脱盘模式")])+ management = app[app.index("function enterManagementSurface()"):+ app.index("async function openStats")]+ self.assertNotIn("postSetupTutorial", management)self.assertIn("const pending=visible.filter(task=>!task.done)", app)self.assertIn("data-tutorial-collapse", app)self.assertIn("data-tutorial-skip", app)self.assertIn("setPostSetupTutorialCollapsed(collapsed)", app)self.assertIn("href:'/data-cleanup',done:libraryReady", app)self.assertIn("icon(collapsed?'chevron-up':'chevron-down')", app)+ self.assertIn("if(!root.firstElementChild){", tutorial)+ self.assertIn("if(root.dataset.tutorialSignature===signature){root.removeAttribute('aria-busy');return}", tutorial)+ self.assertIn("root.dataset.tutorialSignature=signature", tutorial)self.assertIn("if(!pending.length){", app)self.assertIn("setPostSetupTutorialMarker('complete');root.hidden=true", app)self.assertIn("actionReceipt(`已跳过", app)@@ -172,6 +181,8 @@ class WebUiSourceTests(unittest.TestCase):self.assertIn("width:min(400px,calc(100vw - 24px))", board)self.assertIn("pointer-events:none", board)self.assertIn(".post-setup-notification{pointer-events:auto", board)+ self.assertIn(".post-setup-notification-head{display:grid;grid-template-columns:40px minmax(0,1fr) 32px;align-items:center", board)+ self.assertIn("width:32px;height:32px;margin:0 -4px 0 0", board)self.assertIn(".post-setup-notification[data-collapsed=true]>.post-setup-task-list", board)self.assertIn(".post-setup-skip:hover", board)self.assertIn("color:var(--color-text-secondary);fill:none;stroke:currentColor", board)@@ -1899,7 +1910,7 @@ class WebUiSourceTests(unittest.TestCase):# 目录页四个筛选态的标题就是筛选名本身,和侧栏取同一份 STATE_LABELS。self.assertPageContains("title:STATE_LABELS[key],open:()=>openCatalog(path)")self.assertPageContains('syncPageTitle(path);')- self.assertPageContains('queueMicrotask(()=>{syncHeaderActions();paintListTitle();buildDrawerNavigation()})')+ self.assertPageContains('queueMicrotask(()=>{syncHeaderActions();paintListTitle();buildDrawerNavigation();void syncPostSetupTutorial()})')self.assertPageContains("queueMicrotask(()=>$('#settingsClose').focus())")self.assertPageContains('if(settingsReturnFocus&&document.contains(settingsReturnFocus))')self.assertPageContains("if(e.key!=='Tab')return")diff --git a/web/app.js b/web/app.jsindex e4897f055..78994a4ce 100644--- a/web/app.js+++ b/web/app.js@@ -443,7 +443,7 @@ const route=(path,replace=false)=>{barsRequestSeq++;history[replace?'replaceState':'pushState']({},'',path);syncPageTitle(path);lastRoutePath=decodeURIComponent(new URL(path,location.href).pathname);- queueMicrotask(()=>{syncHeaderActions();paintListTitle();buildDrawerNavigation()});+ queueMicrotask(()=>{syncHeaderActions();paintListTitle();buildDrawerNavigation();void syncPostSetupTutorial()});};/* ── 脱盘模式 ─────────────────────────────────────────────────────────────────@@ -1272,8 +1272,8 @@ const postSetupTutorialSkipped=()=>{const setPostSetupTutorialSkipped=values=>{try{localStorage.setItem(POST_SETUP_TUTORIAL_SKIPPED_KEY,JSON.stringify([...values]))}catch(_error){}};-/* `onboarding=1` 来自设置完成页。历史导入可以先去口味页,但标记会一直留到用户- 第一次回首页;清单只读真实接口,不用“访问过页面”冒充完成。 */+/* `onboarding=1` 来自设置完成页。历史导入可以先去口味页,标记会在 Peach 的每一页+ 保持生效;清单只读真实接口,不用“访问过页面”冒充完成。 */if(new URLSearchParams(location.search).get('onboarding')==='1'){setPostSetupTutorialMarker('pending');if(location.pathname==='/'){@@ -1335,7 +1335,7 @@ const postSetupTutorialHtml=(tasks,skippedCount,totalCount)=>{</li>`).join('');return `<article class="post-setup-notification" data-collapsed="${collapsed}"><header class="post-setup-notification-head">- <span class="post-setup-notification-icon" aria-hidden="true">${icon('sparkles')}</span>+ <span class="post-setup-notification-icon" aria-hidden="true">${icon('compass')}</span><div><h2>完成 Peach 的安装教程</h2><p>已处理 ${completeCount}/${totalCount} 项,完成后会自动打勾。</p></div><button class="post-setup-collapse" type="button" data-tutorial-collapse aria-controls="postSetupTaskList" aria-expanded="${!collapsed}"@@ -1347,23 +1347,29 @@ const postSetupTutorialHtml=(tasks,skippedCount,totalCount)=>{};async function syncPostSetupTutorial(){const root=$('#postSetupTutorial');if(!root)return;- if(location.pathname!=='/'||postSetupTutorialMarker()!=='pending'){- root.hidden=true;root.innerHTML='';return+ if(postSetupTutorialMarker()!=='pending'){+ root.hidden=true;root.innerHTML='';delete root.dataset.tutorialSignature;return}const request=++postSetupTutorialRequest;root.hidden=false;root.setAttribute('aria-busy','true');- root.innerHTML=`<article class="post-setup-notification post-setup-loading">${icon('sparkles')}<p>正在检查安装进度…</p></article>`;+ if(!root.firstElementChild){+ root.innerHTML=`<article class="post-setup-notification post-setup-loading">${icon('compass')}<p>正在检查安装进度…</p></article>`;+ }try{const tasks=await postSetupTutorialTasks();- if(request!==postSetupTutorialRequest||location.pathname!=='/')return;+ if(request!==postSetupTutorialRequest)return;const knownKeys=new Set(tasks.map(task=>task.key));const skipped=new Set([...postSetupTutorialSkipped()].filter(key=>knownKeys.has(key)));setPostSetupTutorialSkipped(skipped);const visible=tasks.filter(task=>!skipped.has(task.key));const pending=visible.filter(task=>!task.done);if(!pending.length){- setPostSetupTutorialMarker('complete');root.hidden=true;root.innerHTML='';root.removeAttribute('aria-busy');return+ setPostSetupTutorialMarker('complete');root.hidden=true;root.innerHTML='';delete root.dataset.tutorialSignature;+ root.removeAttribute('aria-busy');return}- root.innerHTML=postSetupTutorialHtml(visible,skipped.size,tasks.length);root.removeAttribute('aria-busy');+ const signature=JSON.stringify(visible.map(task=>[task.key,task.done,task.label,task.description,task.href]));+ if(root.dataset.tutorialSignature===signature){root.removeAttribute('aria-busy');return}+ root.innerHTML=postSetupTutorialHtml(visible,skipped.size,tasks.length);+ root.dataset.tutorialSignature=signature;root.removeAttribute('aria-busy');const next=pending[0];const collapse=root.querySelector('[data-tutorial-collapse]');collapse.onclick=()=>{@@ -1388,7 +1394,7 @@ async function syncPostSetupTutorial(){};}catch(_error){if(request!==postSetupTutorialRequest)return;- root.innerHTML=`<article class="post-setup-notification post-setup-error">${icon('alert')}<div><h2>暂时无法检查安装进度</h2><p>Peach 会在你下次回到首页时重新检查。</p></div></article>`;+ root.innerHTML=`<article class="post-setup-notification post-setup-error">${icon('alert')}<div><h2>暂时无法检查安装进度</h2><p>Peach 会在你切换页面或重新打开后检查。</p></div></article>`;root.removeAttribute('aria-busy');}}@@ -4506,7 +4512,6 @@ function enterManagementSurface(){// the management page after it resolves.loadRequestSeq++;listLoading=false;$('#combo').innerHTML='';hideDiscoveryBars();- const tutorial=$('#postSetupTutorial');if(tutorial){tutorial.hidden=true;tutorial.innerHTML=''}document.body.classList.remove('entity-open','index-open');}async function openStats(push=true){@@ -4534,7 +4539,6 @@ function showHomeSurfaces(){$('#stats').hidden=true;$('#index').hidden=true;$('#tiers').style.display='';$('#tagbar').style.display='';buildManageBar();paintListTitle(); // 放在最后:管理区要盖掉上面刚恢复的首页横条- void syncPostSetupTutorial();}function closeStats(push=true){if(push)route('/');showHomeSurfaces();load(true)}@@ -9844,7 +9848,6 @@ function openCatalog(path){state:ROUTE_STATES[path]||params.get('state')||'',...resolveSort(params.get('sort'),params.get('dir')),seed:params.get('seed')||(enteringHome?rollSeed():state.seed||rollSeed()),q:params.get('q')||'',jav:params.get('jav')||''};$('#q').value=state.q;rememberSearchValue();buildEdge();buildBars();load(true);- void syncPostSetupTutorial();}/* 回收站。它和目录页共用同一张网格,只是筛选被钉死成 `trash`。 */function openTrash(push){@@ -9883,6 +9886,7 @@ async function restoreRoute(){syncPageTitle(location.href);buildDrawerNavigation();const path=decodeURIComponent(location.pathname);+ void syncPostSetupTutorial();if(path==='/'&&new URLSearchParams(location.search).get('state')==='ads'){route(junkPath(),true);await restoreRoute();return;}diff --git a/web/board.css b/web/board.cssindex c5d4ad90e..387ebf0b1 100644--- a/web/board.css+++ b/web/board.css@@ -1582,17 +1582,17 @@ body .followmanage .board-pagination>.geist-button{height:32px;min-height:32px;p.pcheck input:checked+span svg{animation:board-check-draw .2s cubic-bezier(.65,0,.35,1) forwards}@media(prefers-reduced-motion:reduce){.pcheck input:checked+span svg{animation:none;stroke-dashoffset:0}}-/* 安装后第一次回首页:BoardUI NotificationViewport 把教程固定在右下角,内部任务沿用- RareUI Task List 的真实状态、完成项后移与打勾,不占首页正文的布局空间。 */+/* 安装后教程:BoardUI NotificationViewport 把教程固定在右下角,内部任务沿用 RareUI+ Task List 的真实状态、完成项后移与打勾,不占当前页面正文的布局空间。 */#postSetupTutorial{position:fixed;right:12px;bottom:12px;z-index:100;display:block;width:min(400px,calc(100vw - 24px));max-height:calc(100dvh - 24px);pointer-events:none}#postSetupTutorial[hidden]{display:none}.post-setup-notification{pointer-events:auto;display:flex;flex-direction:column;max-height:inherit;overflow:hidden;border:1px solid var(--color-border-button-default);border-radius:16px;background:var(--color-background-primary-default);box-shadow:0 1px 1px #0000000d,0 4px 4px #0000001a;animation:post-setup-notification-in .15s ease-out}-.post-setup-notification-head{display:grid;grid-template-columns:40px minmax(0,1fr) 32px;align-items:start;gap:12px;padding:16px}+.post-setup-notification-head{display:grid;grid-template-columns:40px minmax(0,1fr) 32px;align-items:center;gap:12px;padding:16px}.post-setup-notification-icon{display:grid;place-items:center;width:40px;height:40px;border-radius:50%;background:var(--color-notification-information-background);color:var(--color-notification-information-foreground)}.post-setup-notification-icon>svg,.post-setup-error>svg,.post-setup-loading>svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:2}.post-setup-notification h2{margin:0;color:var(--color-text-primary);font:var(--board-body-medium)}.post-setup-notification p{margin:4px 0 0;color:var(--color-text-secondary);font:var(--board-body-2-regular)}-.post-setup-collapse{display:grid;place-items:center;width:32px;height:32px;margin:-4px -4px 0 0;padding:0;border:0;border-radius:8px;background:transparent;color:var(--color-text-secondary)}+.post-setup-collapse{display:grid;place-items:center;width:32px;height:32px;margin:0 -4px 0 0;padding:0;border:0;border-radius:8px;background:transparent;color:var(--color-text-secondary)}.post-setup-collapse:hover{background:var(--color-background-primary-hover);color:var(--color-text-primary)}.post-setup-collapse>svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2}.post-setup-notification[data-collapsed=true]>.post-setup-task-list,.post-setup-notification[data-collapsed=true]>footer{display:none}