Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(web): 检查回执带去看更新动作,批量操作改为按钮

longmeidao6d7fc7334af0
diff --git a/docs/STATUS.md b/docs/STATUS.md
index ba78efa43..e3d5801f0 100644
--- a/docs/STATUS.md
+++ b/docs/STATUS.md
@@ -36,6 +36,7 @@
## 本批修正与验证
+- 2026-08-29 按用户复核意见改两处关注反馈:检查回执 toast 带具名动作「去看更新」(点击关掉自己并跳转关注流),统计文案收掉悬空的「条详情」——它曾被当成可点的链接;关注管理的批量操作(全部标记已看/全部忽略)从计数行内的裸链接改为独立 `.fbulk` 行的 `.fbtn` 次级按钮,与本页「检查全部/去看更新」同一套控件语言。follow 427 项通过;生产页面实测:toast 动作点击后正确跳转 `/follow`,批量按钮渲染正常,全程未触发真实检查、未写 ledger。
- 2026-08-29 关注检查反馈对齐 Geist toast 处方(取证:`docs/reference-snapshots/vercel-geist-toast.md`):「检查了 N 个来源」改为右下角 toast(挂 body 直下,整页重画冲不掉,自动消失、hover 暂停、右上角关闭,`aria-live="polite"`);失败只发一句短 toast,原因明细留在管理页内的持久行(`.fcheckreport`,左侧红条 + 恢复入口),关注页的持久失败状态走重排后的 `.fwarn`(图标 + 行内链接,修掉链接前 10px 死间距与缩小字号)。全站转圈动画并成一套 `peach-spin`:检查更新、检查全部、抓更早的一页、扫描差异、同步并清理、读取浏览器、顶栏换一批统一为按钮 busy 类 + 图标自转,「抓更早的一页」不再丢图标。新增顶栏「审查遮挡」开关(`#censorBtn`):默认开启——封面与预览图以原始画面进截图会被截图管道的审查拦下(关注页实测),localStorage 只记用户显式关闭;开启后全站内容图与视频(含 videojs 海报层、悬停预览、沉浸模式、关注流封面/详情海报/图片墙)统一重糊去饱和压暗,悬停预览同时不再启动;品牌标与来源 favicon 豁免。上一轮遗留的 4 处 catalog 源码契约(settingscard 主题覆盖顺序、滑杆轨道 pill 字面量、换一批重置种子精确串、搜索聚焦环 color-mix 断言)一并修正,`follow` 426 项、`catalog` 405 项通过。
- 2026-08-29 按检视报告做架构优化,六批独立提交、每批全量回归。`web_contract.py` 3294 → 1899 行:资源对账拆为 `web_resource_sync`,复核队列拆为 `web_review`,两者都用 Protocol 只声明各自需要的能力;拆分暴露的三处循环依赖靠下沉纯规则解决(`dir_expr`/`GENERIC_PHOTO_DIRS`/`photo_set_title` → `catalog_rules`,`_resolve_entity` → `entities.resolve_entity`)。`web_logic.py` 改名 `catalog_rules.py`——那 206 行没有一行是 web 的却被数据层依赖,倒置的是名字不是方向;新增 `test_module_layering` 锁住分层。follow 域:删除 ADR-0007 的 RSS 适配层与 `feedparser` 依赖(ADR-0007 已标 Superseded by 0019),provider 元数据收进 `follow_providers` 单点登记表(凭据策略刻意留在 `CREDENTIAL_GUIDE`),八个连接器的取回骨架抽成 `_BaseConnector._request()`,探测能力转正为 `probe`/`fetch_json`/`parse_json`。`w_item_tag` 改走 `write_transaction`,顺带修掉「除资产不存在外任何 execute 抛出都既不回滚也不关连接」。`test_rm_web.py` 2428 → 1512 行,测试随领域同批拆出;拆带 patch 的域时 patch 目标必须跟着代码走,否则静默失效。全量 1188 → 1206 项通过。
- 2026-08-29 清理仓库与顶层目录。分支 79 → 4(`master`、`agent/codex/taste-analysis`、`preserve/windows-review-ads-20260822`、当前会话分支),工作树 76 → 3;删掉的 73 个是已合并进 master 的 agent 分支,另有三个被 master 等价实现超越的分支按 SHA 记录后删除(`62e7618`、`cb4b044`、`d2ae77d`),SHA 存于 `../attic/README.md`。顶层 12 个目录收敛为 4 个 `peach-*` 运行时目录加一个 `attic/`:`peach-` 前缀此后专属 ADR-0017 定义的 `peach-app`/`peach-data`/`peach-sync`/`peach-worktrees`,其余按 `builds`/`evidence`/`instances`/`tools`/`reviews` 五类归入 `attic/`,日期统一写成 `YYYYMMDD-主题`。规则与本次映射写在 `../attic/README.md`,不进 Git(顶层非仓库)。删除的只有空目录 `verification` 与 `__pycache__`;账本副本、复核产物、取证归档一律保留。
diff --git a/tests/test_follow_web.py b/tests/test_follow_web.py
index af48924f5..3a6e937e3 100644
--- a/tests/test_follow_web.py
+++ b/tests/test_follow_web.py
@@ -1527,6 +1527,24 @@ class FollowWebSourceTests(unittest.TestCase):
self.assertPageContains(needle)
# 失败要说清是哪个站,不能让用户去猜 `rule34xxx` 是什么。
self.assertPageContains("row.provider_label||row.provider")
+ # 回执带一个具名的后续动作:光摆数字会让人去点「…条详情」那半句,
+ # 文案里不再留悬空的「详情」,去看更新作为显式按钮接住这个意图。
+ self.assertPageContains("action:{label:'去看更新',run:()=>openFollow()}")
+ self.assertPageContains("if(action)item.querySelector('.tact')")
+ self.assertPageLacks("条详情")
+
+ def test_follow_bulk_actions_are_buttons_not_inline_links(self):
+ """批量标记已看/全部忽略是 2292 条级别的操作,不能长得像行内文字链接。
+
+ 裸蓝字链接和旁边的计数文本混在一行里,看起来像一句说明文字;
+ 分不清哪半句是统计、哪半句可以点。改成 .fbtn 次级按钮——与本页
+ 「检查全部/去看更新」同一套控件语言——按钮的边界让「这会改状态」
+ 在点击之前就看得见。
+ """
+ self.assertPageContains('<button class="fbtn" data-follow-bulk="seen">全部标记已看</button>')
+ self.assertPageContains('<button class="fbtn" data-follow-bulk="ignored">全部忽略</button>')
+ self.assertPageLacks('class="flink" data-follow-bulk')
+ self.assertPageContains('.fbulk{display:flex;gap:8px;margin:8px 0 0}')
def test_sources_by_the_same_author_are_one_block(self):
"""同一个作者在几个站上是几条来源、一个人。
diff --git a/web/app.css b/web/app.css
index 233a79e58..6cc056e43 100644
--- a/web/app.css
+++ b/web/app.css
@@ -1039,10 +1039,14 @@ body.settings-open{overflow:hidden}
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}
-.toast button{flex:none;width:24px;height:24px;padding:0;border:0;border-radius:var(--control-radius);
+/* 动作是具名的下一步(去看更新),文字按钮跟正文同行;关闭才是 24px 图标位。 */
+.toast .tact{flex:none;align-self:center;border:0;background:none;padding:0;
+ color:var(--tungsten);font:inherit;font-size:var(--fs-sm);cursor:pointer}
+.toast .tact:hover{text-decoration:underline}
+.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 button:hover{background:var(--hover);color:var(--ink)}
-.toast button svg{width:13px;height:13px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round}
+.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}
/* ── 审查遮挡 ──
@@ -1508,6 +1512,9 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位
.fcheckreport b{color:var(--ink);font-variant-numeric:tabular-nums}
.fcheckfail{color:var(--drop)}
.fchecknote{color:var(--muted);font-size:var(--fs-xs)}
+/* 批量动作是 2292 条级别的操作,不是行内文字链接:按钮的边界让「这会改状态」
+ 在点击前就看得见,也和本页其他 .fbtn(检查全部/去看更新)同一套语言。 */
+.fbulk{display:flex;gap:8px;margin:8px 0 0}
/* 状态标签:四种状态四种颜色,待办和完成一眼分得开。 */
/* 凭据状态。类名不能叫 `.fstate`——观看页的卡片错误行已经占了那个名字
diff --git a/web/app.js b/web/app.js
index f22d086c0..4dcf50957 100644
--- a/web/app.js
+++ b/web/app.js
@@ -178,17 +178,22 @@ const emptyState=(ic,title,desc)=>`<div class="emptystate"><div class="es-icon">
/* Toast:挂在 #toasts(body 直下)而不是 #stats 里——检查完会整页重画,
页内浮层会被冲掉,这里不会。对齐 Geist 的处方(取证见
docs/reference-snapshots/vercel-geist-toast.md):只做用户主动动作的
- 非阻塞回执,自动消失;hover 暂停计时,右上角关闭。失败这类必须跟进的
+ 非阻塞回执,自动消失;hover 暂停计时,右上角关闭。回执可以带一个
+ 明确的后续动作(action.label + action.run):光摆数字会让用户去找
+ 「哪里能点」,Geist 的做法是给一个具名的下一步。失败这类必须跟进的
事只发一句短 toast,原因和恢复入口留在页面里的持久行上。 */
-const toast=(html,{timeout=6000,warn=false}={})=>{
+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><button title="关闭" aria-label="关闭提示">${icon('x')}</button>`;
+ 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>`;
let timer=null;
const close=()=>{clearTimeout(timer);item.classList.add('leaving');
setTimeout(()=>item.remove(),160)};
- item.querySelector('button').onclick=close;
+ item.querySelector('.tclose').onclick=close;
+ if(action)item.querySelector('.tact').onclick=()=>{close();action.run()};
const arm=()=>{if(timeout)timer=setTimeout(close,timeout)};
item.addEventListener('mouseenter',()=>clearTimeout(timer));
item.addEventListener('mouseleave',arm);
@@ -1900,7 +1905,7 @@ function followCheckBits(report){
if(compilations)bits.push(`排除 <b>${compilations}</b> 个超大合集`);
// 回查是唯一会放大请求数的路径,报出来才看得出某个作者是不是每帖都要多打一次站点。
const probed=rows.reduce((n,r)=>n+(r.probed||0),0);
- if(probed)bits.push(`回查 <b>${probed}</b> 条详情`);
+ if(probed)bits.push(`回查 <b>${probed}</b> 条`);
if(quiet)bits.push(`${quiet} 个来源没有更新`);
if(!bits.length)bits.push('没有任何更新');
return {rows,bits};
@@ -1909,7 +1914,9 @@ function followCheckToast(report){
const {rows,bits}=followCheckBits(report);
const failed=rows.filter(r=>!r.ok).length;
toast(`检查了 <b>${rows.length}</b> 个来源:${bits.join(' · ')}`+
- (failed?` · <b>${failed} 个失败</b>`:''),{warn:!!failed,timeout:failed?8000:6000});
+ (failed?` · <b>${failed} 个失败</b>`:''),
+ {warn:!!failed,timeout:failed?8000:6000,
+ action:{label:'去看更新',run:()=>openFollow()}});
}
/* 页内持久行:只装失败与取证缺档,渲染在管理页自己的检查区里。全部成功时
返回空串——成功摘要整条交给 toast,页面上不再出现通栏横条。关注页不渲染
@@ -2337,9 +2344,9 @@ function renderFollowManage(credentials){
${sources.length?`<div class="frows fsources">${
followAuthorGroups(sources).map(followAuthorBlock).join('')}</div>
${counts.new?`<p class="fnote">未看 ${counts.new} · 已看 ${counts.seen||0}
- · 已保存 ${counts.saved||0} · 已忽略 ${counts.ignored||0}
- <button class="flink" data-follow-bulk="seen">全部标记已看</button>
- <button class="flink" data-follow-bulk="ignored">全部忽略</button></p>`:''}`
+ · 已保存 ${counts.saved||0} · 已忽略 ${counts.ignored||0}</p>
+ <div class="fbulk"><button class="fbtn" data-follow-bulk="seen">全部标记已看</button>
+ <button class="fbtn" data-follow-bulk="ignored">全部忽略</button></div>`:''}`
:'<p class="fnote">还没有关注任何来源。</p>'}
</section>
</div>