Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(follow): 检查会报结果了;同一作者的多个来源合成一组并显示头像

Peach local maintenance03d5de15d81e
diff --git a/docs/reference-snapshots/vercel-geist-controls-measured.md b/docs/reference-snapshots/vercel-geist-controls-measured.md
index f04101a44..b6d83af61 100644
--- a/docs/reference-snapshots/vercel-geist-controls-measured.md
+++ b/docs/reference-snapshots/vercel-geist-controls-measured.md
@@ -78,3 +78,45 @@ token 上;`app.css` 里除 iOS 那条之外出现任何字面字号都会红
继续使用自己的 `--tungsten` 主色和既有暗色表面变量,不引入 Geist 的调色板或字体。
这是有意的差异,不是没做完。
+
+## 关注来源的头像与主题色取证(2026-08-27)
+
+用户要「同一作者跨来源合并并显示头像」和「按站点主题色描边」,两件都要先取证。
+
+### 头像:kemono 系拿得到,rule34 系未取得
+
+`curl`(不带凭据,`--noproxy '*'`):
+
+| 端点 | 结果 |
+| --- | --- |
+| `https://kemono.cr/icons/fanbox/30917150` | 302 → `img.kemono.cr/icons/...`,200 `image/webp` 160×160 |
+| `https://pawchive.pw/icons/fanbox/30917150` | 200,14,534 字节 |
+| `https://coomer.st/icons/fanbox/30917150` | 404 |
+
+浏览器里另测一次同一 URL(`new Image()` + `referrerPolicy='no-referrer'`):`load 160x160`。
+所以页面直接引用这个地址是可行的,不需要服务端代理。
+
+coomer 那个 404 **只说明这个创作者不在 coomer 上**,不能据此断定 coomer 没有这个端点——
+所以代码照样按同一规则给它 URL,取不到时由 `<img onerror>` 收场。
+
+rule34video / rule34.xxx **未取得**:本机账本里没有这两个站的来源行,拿不到真实的作者页
+样本可测(试过的一个 `/members/<id>/` 回 404,那只说明 id 是编的)。不猜路径。
+取不到头像时界面显示一个明确的空位,**不用首字母冒充**——首字母会让「未取得」看着像取到了。
+
+### 主题色:未取得,不要按印象填
+
+想用 `<meta name="theme-color">` 当品牌色,实测这条路走不通:
+
+| 站点 | `theme-color` |
+| --- | --- |
+| rule34video.com | `#ffffff` |
+| f95zone.to | `#181a1d` |
+| kemono.cr / coomer.st / pawchive.pw | 无(页面是 JS 渲染的,首屏 HTML 不到 2 KB) |
+| rule34.xxx | 取不到(对 `curl` 回 403) |
+
+`theme-color` 是浏览器 UI 底色,不是品牌色——rule34video 的白和 f95zone 的深灰都只是
+各自页面底色。favicon 兜底也不成立:kemono 系 `/favicon.ico` 404,而 rule34video 和
+f95zone 回的字节数完全相同(15,086),一看就不是各自的图标。
+
+**结论是未取得**,边框颜色这一条没有可复现的依据可用,没有实现。要做得先定一个能复核的
+口径(例如从各站主 CSS 里取按钮/链接的强调色,并记下文件哈希)。
diff --git a/src/peach/web_follow.py b/src/peach/web_follow.py
index c9ee3e5c4..453b9c62c 100644
--- a/src/peach/web_follow.py
+++ b/src/peach/web_follow.py
@@ -7,6 +7,7 @@ from __future__ import annotations
import json
import os
+import re
from datetime import datetime, timezone
from .follow import FollowSourceError
@@ -77,6 +78,55 @@ def _group_payload(group: ReleaseGroup) -> dict:
}
+#: 标签里跟在中点后面的服务名。`LazyProcrastinator · fanbox` 和 rule34video 上的
+#: `lazyprocrastinator` 是同一个人,中点后面那截只说明他在哪个平台连载。
+_LABEL_SERVICE_RE = re.compile(r"\s*[·|]\s*[A-Za-z0-9_\-]+\s*$")
+_AUTHOR_NOISE_RE = re.compile(r"[^0-9a-z一-鿿]+")
+
+
+def author_key(row) -> str:
+ """把一条来源归到「哪个作者」。
+
+ 这跟 ADR-0019 的变体分组**不是同一个轴**:那个是同一条发布的多个变体,
+ 这个是同一个作者在不同站点上的多条来源。用户在 Kemono 和 Pawchive 上关注的
+ `LazyProcrastinator · fanbox`、在 Rule34Video 和 Rule34.xxx 上关注的
+ `lazyprocrastinator`,是四条来源、一个人。
+
+ 实体已经绑上就用实体 id——那是规范身份,比名字可靠。没绑才退回名字归一化:
+ 去掉「· 服务名」后缀,再去掉大小写、空格、连字符这些不影响身份的噪声。
+ 归一化只做到这一步,不做模糊匹配:把两个碰巧相似的名字并成一个人,
+ 比让用户自己看到两行严重得多。
+ """
+ entity = row["entity_id"]
+ if entity:
+ return f"entity:{entity}"
+ label = str(row["label"] or row["ref"] or "")
+ stripped = _LABEL_SERVICE_RE.sub("", label)
+ normalized = _AUTHOR_NOISE_RE.sub("", stripped.casefold())
+ return f"name:{normalized}" if normalized else f"source:{row['id']}"
+
+
+def _avatar_url(provider: str, ref: str) -> str | None:
+ """作者头像。**只有实测拿得到的来源才给,取不到就是 `None`。**
+
+ 2026-08-27 实测(`curl`,不带凭据):
+ `https://kemono.cr/icons/fanbox/30917150` → 302 → `img.kemono.cr`,
+ 200 `image/webp` 160×160;`pawchive.pw` 同路径 200、14,534 字节。
+ coomer.st 对这个创作者回 404,但那只说明他不在 coomer 上,
+ 不能据此断定 coomer 没有这个端点——所以 coomer 照样按同一规则给 URL,
+ 取不到时由 `<img onerror>` 收场。
+
+ rule34video / rule34.xxx **未取得**:没有可用的作者页样本可测,不猜一个路径。
+ 取不到头像时界面显示站点缩写,不用首字母假装成头像。
+ """
+ if provider not in KemonoConnector.HOSTS:
+ return None
+ service, _, user = str(ref or "").partition("/")
+ if not service or not user:
+ return None
+ return f"https://{KemonoConnector.HOSTS[provider]}/icons/{service}/{user}"
+
+
def _source_payload(row) -> dict:
return {
"id": row["id"],
@@ -84,6 +134,8 @@ def _source_payload(row) -> dict:
"provider_label": PROVIDER_LABELS.get(row["provider"], row["provider"]),
"ref": row["ref"],
"label": row["label"],
+ "author_key": author_key(row),
+ "avatar_url": _avatar_url(row["provider"], row["ref"]),
"url": row["url"],
"semantics": row["semantics"],
"enabled": bool(row["enabled"]),
@@ -203,7 +255,9 @@ def w_follow_check(contract, body) -> dict:
row["id"], fetch,
creator_aliases=store.creator_aliases(row["entity_id"]), moment=moment)
results.append({
- "source": row["id"], "provider": provider, "ref": ref, "ok": True,
+ "source": row["id"], "provider": provider,
+ "provider_label": PROVIDER_LABELS.get(provider, provider),
+ "ref": ref, "label": row["label"], "ok": True,
"not_modified": outcome.not_modified, "discovered": outcome.discovered,
"added": outcome.added, "updated": outcome.updated,
# 证据没存下来不算检查失败,但界面必须说出来,不能悄悄少一份原始响应。
@@ -216,7 +270,10 @@ def _failure(contract, row, error, moment, status) -> dict:
with contract.database.write_transaction() as connection:
_store(contract, connection).record_error(
row["id"], str(error), moment, status=status)
- return {"source": row["id"], "provider": row["provider"], "ref": row["ref"],
+ # 界面按人看得懂的站名和来源标签报失败,不让用户去猜 `rule34xxx` 是哪个站。
+ return {"source": row["id"], "provider": row["provider"],
+ "provider_label": PROVIDER_LABELS.get(row["provider"], row["provider"]),
+ "ref": row["ref"], "label": row["label"],
"ok": False, "status": status, "error": str(error)}
diff --git a/tests/test_follow_web.py b/tests/test_follow_web.py
index e4f8b18b8..23773e10e 100644
--- a/tests/test_follow_web.py
+++ b/tests/test_follow_web.py
@@ -538,6 +538,10 @@ class FollowWebSourceTests(unittest.TestCase):
if needle not in self.page:
self.fail(f"Web 表面缺少:{needle!r}" + (f"({message})" if message else ""))
+ def assertPageLacks(self, needle, message=""):
+ if needle in self.page:
+ self.fail(f"Web 表面不应出现:{needle!r}" + (f"({message})" if message else ""))
+
def test_watching_lives_in_the_left_rail_and_managing_stays_in_the_manage_area(self):
# 看和管是两件事,两个页面:左侧导航进「看」,管理区进「管」。
# 断言「相邻」这件事本身,不要连换行和缩进一起写死——那种断言一改格式就红,
@@ -826,10 +830,96 @@ class FollowWebSourceTests(unittest.TestCase):
self.assertPageContains("""item.status==='seen'||item.status==='ignored'""")
self.assertPageContains(">恢复未看</button>")
+ def test_the_author_key_merges_one_person_across_sites(self):
+ """归组判据:实体优先,其次名字归一化,绝不模糊匹配。
+
+ 把两个碰巧相似的名字并成一个人,比让用户自己看到两行严重得多——
+ 前者会把别人的更新混进来且很难发现。
+ """
+ def key(**row):
+ row.setdefault("entity_id", None)
+ row.setdefault("id", 1)
+ row.setdefault("ref", "")
+ return web_follow.author_key(row)
+
+ # 「· 服务名」只说明他在哪个平台连载,不是身份的一部分。
+ same = {key(label="LazyProcrastinator · fanbox"),
+ key(label="lazyprocrastinator"),
+ key(label="Lazy-Procrastinator")}
+ self.assertEqual(len(same), 1, f"应归成同一个作者,实际 {same}")
+ # 实体绑上之后以实体为准,名字再怎么写都不影响。
+ self.assertEqual(key(label="随便写", entity_id=7), "entity:7")
+ self.assertEqual(key(label="別の人", entity_id=7),
+ key(label="LazyProcrastinator", entity_id=7))
+ # 不同的人不许并。
+ self.assertNotEqual(key(label="bewyx"), key(label="bewyx2"))
+ # 名字为空时退回来源 id,不能让所有空名字挤成一组。
+ self.assertNotEqual(key(label="", id=1), key(label="", id=2))
+
+ def test_avatars_only_come_from_providers_that_actually_serve_one(self):
+ """头像按 peach-reference-evidence:实测拿得到才给,取不到写「未取得」。
+
+ 2026-08-27 实测 `https://kemono.cr/icons/fanbox/30917150` → 302 →
+ `img.kemono.cr`,200 `image/webp` 160×160;pawchive.pw 同路径 200。
+ rule34 系没有可用样本可测,所以不给 URL——不猜一个路径。
+ """
+ self.assertEqual(web_follow._avatar_url("kemono", "fanbox/30917150"),
+ "https://kemono.cr/icons/fanbox/30917150")
+ self.assertEqual(web_follow._avatar_url("pawchive", "fanbox/30917150"),
+ "https://pawchive.pw/icons/fanbox/30917150")
+ for provider, ref in (("rule34video", "1290582"),
+ ("rule34xxx", "lazyprocrastinator"),
+ ("f95zone", "50685"),
+ ("kemono", "no-slash")):
+ self.assertIsNone(web_follow._avatar_url(provider, ref),
+ f"{provider} 没有实测过的头像来源,不该猜一个")
+
def test_a_missing_evidence_archive_is_shown_not_swallowed(self):
- self.assertPageContains("检查完成,但证据未存档")
+ # 证据未存档现在并进那块检查报告,不再单独弹一层——但话不能少说。
+ self.assertPageContains("候选已入库,但这一次的原始响应没有留档")
self.assertPageContains("r.evidence_error")
+ def test_a_check_says_what_it_actually_found(self):
+ """检查完必须报结果。
+
+ 用户的原话是「完全没返回任何结果」:接口每条来源都回了
+ added/updated/not_modified/error,而界面拿到之后只是整页重画,
+ 那些数字一个都没露面,看起来就是点了一下什么都没发生。
+
+ 「没有更新」和「检查失败」在界面上都像「什么都没发生」,但一个不用管,
+ 另一个再不管就会一直漏更新——所以失败必须单独列出来并带上原因。
+ """
+ self.assertPageContains("function followCheckSummary(report)")
+ # 重画会把结果冲掉,所以先存再画。
+ self.assertPageContains("followCheckReport=result;")
+ self.assertPageContains("${followCheckReport?followCheckSummary(followCheckReport):''}")
+ for needle in ("新增 <b>", "更新 <b>", "个来源没有更新", "没有任何更新",
+ "个失败", "fcheckfail"):
+ self.assertPageContains(needle)
+ # 失败要说清是哪个站,不能让用户去猜 `rule34xxx` 是什么。
+ self.assertPageContains("row.provider_label||row.provider")
+
+ def test_sources_by_the_same_author_are_one_block(self):
+ """同一个作者在几个站上是几条来源、一个人。
+
+ 用户截图里 `LazyProcrastinator · fanbox` 出现两次(Kemono / Pawchive)、
+ `lazyprocrastinator` 出现两次(Rule34Video / Rule34.xxx),四行读起来像四个人。
+ 归组用后端算好的 `author_key`,前端不二次猜。
+ """
+ self.assertPageContains("function followAuthorGroups(sources)")
+ self.assertPageContains("source.author_key")
+ self.assertPageContains("followAuthorGroups(sources).map(followAuthorBlock)")
+ # 组标题用作者本人的名字:四条来源合成一组之后还挂着其中一条的平台后缀,
+ # 等于说这一组只属于 fanbox,正是这次要消掉的误读。
+ self.assertPageContains("function followAuthorName(group)")
+ self.assertPageContains("const name=followAuthorName(group);")
+ # 取不到头像时是一个明确的空位,不是首字母——首字母会让「未取得」看着像取到了。
+ self.assertPageContains("这些来源没有可取的头像")
+ avatar = self.page[self.page.index("function followAuthorAvatar(group)"):]
+ avatar = avatar[:avatar.index("function followAuthorBlock")]
+ self.assertNotIn("charAt", avatar, "不许用首字母冒充头像")
+ self.assertIn("source.avatar_url", avatar)
+
def test_credential_dependent_media_is_called_out(self):
self.assertPageContains("媒体需要登录会话才能取,发现本身不需要")
diff --git a/web/app.css b/web/app.css
index a18330fa4..3202f59e7 100644
--- a/web/app.css
+++ b/web/app.css
@@ -1234,6 +1234,19 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位
.fnote code{font-size:var(--fs-xs)}
[data-follow-add-state]{color:var(--ink-2)}
+/* 检查结果。这块必须留在页面上——检查完会整页重画,浮层或 alert 都会被冲掉,
+ 用户看到的就只是一次闪烁。失败那一路加左侧色条,因为「没有更新」和「检查失败」
+ 在文字上都像「什么都没发生」,得有个不用读就能分辨的信号。 */
+.fcheckreport{margin:10px 0 0;padding:9px 12px;border-radius:var(--control-radius);
+ background:var(--overlay-5);border-left:2px solid var(--line);
+ font-size:var(--fs-sm);line-height:1.7;color:var(--ink-2)}
+.fcheckreport.warn{border-left-color:var(--drop)}
+.fcheckreport p{margin:0}
+.fcheckreport b{color:var(--ink);font-variant-numeric:tabular-nums}
+.fcheckreport .flink{margin-left:8px}
+.fcheckfail{color:var(--drop)}
+.fchecknote{color:var(--muted);font-size:var(--fs-xs)}
+
/* 状态标签:四种状态四种颜色,待办和完成一眼分得开。 */
/* 凭据状态。类名不能叫 `.fstate`——观看页的卡片错误行已经占了那个名字
(`flex:1 1 100%;color:var(--drop)`),撞名会让这里整列变成红色独占一行。
@@ -1284,6 +1297,26 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位
.frow .fmeta{flex:0 0 auto}
.frowerr{flex:1 1 100%;margin:2px 0 0;font-size:var(--fs-sm);line-height:1.6;color:var(--drop)}
.fsource.bad>b{color:var(--drop)}
+
+/* 作者分组。同一个人在几个站上是几条来源、一个人,所以头像和名字只出现一次,
+ 下面才是各站那几行。分组之间用发丝线隔开,不套框——按 vercel-report-design,
+ 卡片套卡片和用边框补救层级都是要拒绝的。
+
+ 这段必须排在 `.frow` 之后:测试用 `index('.frow{')` 取那条规则的正文,
+ 放前面的话选择器里的同名片段会被先匹配到,取回来的是这里的规则。 */
+.fauthor{border-top:1px solid var(--line-soft)}
+.fauthor:first-child{border-top:0}
+.fauthorhead{display:flex;align-items:center;gap:9px;padding:10px 0 6px}
+.fauthorhead b{font-size:var(--fs-md);min-width:0;overflow:hidden;
+ text-overflow:ellipsis;white-space:nowrap}
+.fauthorhead .fmeta{margin-left:auto;flex:none}
+.fauthorhead .fmeta.warn{margin-left:0}
+.fauthor .fsource.frow{padding-left:37px}
+.favatar{width:28px;height:28px;flex:none;border-radius:var(--pill-radius);object-fit:cover;
+ background:var(--overlay-5);outline:1px solid oklch(1 0 0 / 0.1);outline-offset:-1px}
+/* 取不到头像时是一个明确的空位,不是首字母——首字母会让「未取得」看着像取到了。 */
+.favatar.none{display:grid;place-items:center;color:var(--muted);
+ font-size:var(--fs-xs);outline-color:var(--line-soft)}
.flink{border:0;background:none;padding:0;margin-left:10px;color:var(--tungsten);font:inherit;
font-size:var(--fs-sm);cursor:pointer}
/* 猜你喜欢:一行可点的名字,点了直接拿去查。 */
diff --git a/web/app.js b/web/app.js
index a57e16ebd..484e04764 100644
--- a/web/app.js
+++ b/web/app.js
@@ -1232,6 +1232,10 @@ async function openQualityGoals(push=true){
以及对内容做批量标记。
联网只发生在管理页点「检查更新」的那一刻——看的那一页不联网。 */
let followData=null,followRuntime=null,followFilter='new',followBusy=false;
+/* 上一次检查的结果。检查完页面会整页重画,如果不把结果留在这里,用户看到的就只是
+ 一次闪烁——他的原话是「完全没返回任何结果」。接口其实每条来源都回了
+ added/updated/not_modified/error,是界面把它们全丢了。 */
+let followCheckReport=null;
const FOLLOW_FILTERS=[['new','未看'],['seen','已看'],['saved','已保存'],['ignored','已忽略'],['','全部']];
/* 账本里一律存 UTC(ISO 带 Z),界面要按看的人所在时区显示。
@@ -1314,6 +1318,31 @@ function followCard(group){
</div></article>`;
}
+/* 检查完必须说清三件事:新增了什么、哪些确实没有更新、哪些失败了以及为什么。
+ 「没有更新」和「检查失败」在界面上看起来都是「什么都没发生」,但一个不用管,
+ 另一个再不管就会一直漏更新——所以失败必须单独列出来并带上原因。 */
+function followCheckSummary(report){
+ const rows=report.results||[];
+ const failed=rows.filter(r=>!r.ok);
+ const added=rows.reduce((n,r)=>n+(r.added||0),0);
+ const updated=rows.reduce((n,r)=>n+(r.updated||0),0);
+ const quiet=rows.filter(r=>r.ok&&!r.added&&!r.updated).length;
+ const bits=[];
+ if(added)bits.push(`新增 <b>${added}</b> 条`);
+ if(updated)bits.push(`更新 <b>${updated}</b> 条`);
+ if(quiet)bits.push(`${quiet} 个来源没有更新`);
+ if(!bits.length&&!failed.length)bits.push('没有任何更新');
+ const evidence=rows.filter(r=>r.evidence_error);
+ return `<div class="fcheckreport${failed.length?' warn':''}" role="status" aria-live="polite">
+ <p>检查了 ${rows.length} 个来源:${bits.join(' · ')}${
+ failed.length?` · <b>${failed.length} 个失败</b>`:''}
+ <button class="flink" data-check-dismiss>知道了</button></p>
+ ${failed.map(row=>`<p class="fcheckfail">${esc([row.provider_label||row.provider,row.ref]
+ .filter(Boolean).join(' '))}${row.provider?':':''}${esc(row.error||'未说明原因')}</p>`).join('')}
+ ${evidence.length?`<p class="fchecknote">候选已入库,但这一次的原始响应没有留档:${
+ esc(evidence[0].evidence_error)}</p>`:''}</div>`;
+}
+
/* ── 看的那一页 ── */
function renderFollow(){
const groups=followData.groups||[],counts=followData.counts||{};
@@ -1353,6 +1382,60 @@ async function openFollow(push=true){
}
/* ── 管的那一页 ── */
+/* 同一个作者在不同站点上是多条来源、一个人。用户截图里 `LazyProcrastinator · fanbox`
+ 出现两次(Kemono / Pawchive)、`lazyprocrastinator` 出现两次(Rule34Video /
+ Rule34.xxx),四行读起来像四个人。归组用后端给的 `author_key`——那是实体 id
+ 或归一化后的名字,不在前端二次猜。
+
+ 注意这跟卡片里的变体折叠不是同一个轴:那个折的是同一条发布的多个版本,
+ 这里折的是同一个人的多个来源。 */
+function followAuthorGroups(sources){
+ const order=[],byKey=new Map();
+ sources.forEach(source=>{
+ const key=source.author_key||`source:${source.id}`;
+ if(!byKey.has(key)){byKey.set(key,[]);order.push(key)}
+ byKey.get(key).push(source);
+ });
+ return order.map(key=>byKey.get(key));
+}
+
+/* 头像只有实测拿得到的来源才有(kemono 系)。取不到就显示站点缩写,
+ **不用首字母假装成头像**——那会让「没取到」看起来像「取到了」。 */
+function followAuthorAvatar(group){
+ const withIcon=group.find(source=>source.avatar_url);
+ if(withIcon)return `<img class="favatar" src="${esc(withIcon.avatar_url)}" alt=""
+ loading="lazy" referrerpolicy="no-referrer" onerror="this.replaceWith(
+ Object.assign(document.createElement('span'),{className:'favatar none',textContent:'—'}))">`;
+ return '<span class="favatar none" title="这些来源没有可取的头像">—</span>';
+}
+
+/* 分组标题要用作者本人的名字,不是某一条来源的标签。`LazyProcrastinator · fanbox`
+ 里「· fanbox」只说明他在哪个平台连载——四条来源合成一组之后还挂着其中一条的
+ 平台后缀,等于说这一组只属于 fanbox,那正是这次要消掉的误读。
+ 同名的几种写法里取大写最多的那个:`LazyProcrastinator` 比 `lazyprocrastinator`
+ 更像作者自己写的名字。 */
+function followAuthorName(group){
+ const entity=group.find(source=>source.entity_name);
+ if(entity)return entity.entity_name;
+ const names=group.map(source=>String(source.label||'').replace(/\s*[·|]\s*[A-Za-z0-9_-]+\s*$/,''))
+ .filter(Boolean);
+ if(!names.length)return group[0].label||group[0].ref||'';
+ const caps=text=>(text.match(/[A-Z]/g)||[]).length;
+ return names.reduce((best,name)=>caps(name)>caps(best)?name:best,names[0]);
+}
+
+function followAuthorBlock(group){
+ const name=followAuthorName(group);
+ const bad=group.filter(s=>s.last_status==='error'||s.last_status==='unauthorized').length;
+ return `<div class="fauthor${bad?' bad':''}">
+ <div class="fauthorhead">${followAuthorAvatar(group)}
+ <b>${esc(name)}</b>
+ <span class="fmeta">${group.length>1?`${group.length} 个来源`:esc(group[0].provider_label)}</span>
+ ${bad?`<span class="fmeta warn">${bad} 个失败</span>`:''}
+ </div>
+ ${group.map(followSourceRow).join('')}</div>`;
+}
+
function followSourceRow(source){
const state=source.last_status||'未检查';
const bad=state==='error'||state==='unauthorized';
@@ -1431,8 +1514,7 @@ function renderFollowManage(credentials){
?`<a href="${esc(writer)}">前往写入端管理关注</a>`:''}</div>`:''}
<div class="fmain">
<section class="fsec">
- <div class="fsechead"><h3>添加关注</h3>
- <button class="fbtn" data-follow-view>${icon('globe')}去看更新</button></div>
+ <div class="fsechead"><h3>添加关注</h3></div>
<form class="faddform" id="followAdd">
<textarea name="lines" rows="1" required spellcheck="false"
aria-label="来源链接、名字或 id"></textarea>
@@ -1449,9 +1531,12 @@ function renderFollowManage(credentials){
<span class="fmeta">${sources.length} 个来源${
counts.new?` · <b>${counts.new}</b> 条未看`:''}</span>
<button class="fbtn" data-follow-check=""${sources.length?'':' disabled'}>${
- icon('refresh-cw')}检查全部</button></div>
+ icon('refresh-cw')}检查全部</button>
+ <button class="fbtn" data-follow-view>${icon('globe')}去看更新</button></div>
+ ${followCheckReport?followCheckSummary(followCheckReport):''}
${broken.length?`<p class="fnote warn">${broken.length} 个来源上次检查失败,原因见对应那一行。</p>`:''}
- ${sources.length?`<div class="frows">${sources.map(followSourceRow).join('')}</div>
+ ${sources.length?`<div class="frows">${
+ 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>
@@ -1464,9 +1549,8 @@ function renderFollowManage(credentials){
<div class="fsechead"><h3>凭据</h3>
${needCred.length?`<span class="fmeta warn">${needCred.length} 个待配置</span>`:''}</div>
<div class="frows">${creds.map(followCredentialRow).join('')}</div>
- <p class="fnote">写在<b>运行 Peach 的那台机器</b>上,不是你这台浏览器所在的机器。
- 不进 Git、URL、日志或 ledger,保存后页面上不再显示。
- Windows 上不收紧文件权限——NTFS 走 ACL,<code>chmod</code> 在那里没有效果。</p>
+ <p class="fnote">存在<b>运行 Peach 的那台机器</b>上,不进 Git、日志或 ledger。
+ Windows 上不收紧文件权限(NTFS 走 ACL)。</p>
</section>
</aside></div>`;
wireFollowManage();
@@ -1555,21 +1639,18 @@ function wireFollowManage(){
const result=await api('/api/follow/check',{method:'POST',
body:JSON.stringify(id?{source:+id}:{})});
// 一个来源失败不该让其余来源的更新一起消失,所以逐条报,不整体报错。
- const failed=(result.results||[]).filter(r=>!r.ok);
- if(failed.length)console.warn('追更检查失败:',failed);
- /* 证据没存下来不算检查失败,但也不能悄悄少一份原始响应——
- 外置盘没插的时候就是这种情况。 */
- const noEvidence=(result.results||[]).filter(r=>r.evidence_error);
+ /* 结果先留下再重画,否则整页重绘会把它冲掉,用户只看到一次闪烁。
+ 逐条报而不是整体报错:一个来源缺凭据,不该让其余来源的更新一起消失。 */
+ followCheckReport=result;
await openFollowManage(false);
- if(noEvidence.length){
- const box=$('#followPicks');
- if(box)box.innerHTML=`<section class="fpicks"><h3>检查完成,但证据未存档</h3>
- <div class="fpick"><p class="fpickfail">${esc(noEvidence[0].evidence_error)}</p>
- <p>候选已经入库,只是这一次的原始响应没有留档。</p></div>
- <div class="fpickactions"><button data-pick-cancel>知道了</button></div></section>`;
- if(box)box.querySelector('[data-pick-cancel]').onclick=()=>{box.innerHTML=''};
- }
- }catch(e){button.innerHTML=label;alert('检查更新失败:'+e.message)}
+ }catch(e){
+ button.innerHTML=label;
+ // 整个请求就失败了(断网、写入端不可达):同样走那块报告,不弹 alert。
+ followCheckReport={results:[{ok:false,error:e.message}]};
+ const box=$('#stats').querySelector('.fcheckreport');
+ if(box)box.outerHTML=followCheckSummary(followCheckReport);
+ else await openFollowManage(false);
+ }
finally{followBusy=false;button.disabled=false}
});
root.querySelectorAll('[data-follow-guess]').forEach(chip=>chip.onclick=()=>{
@@ -1622,6 +1703,10 @@ function wireFollowManage(){
});
root.querySelectorAll('[data-follow-view]').forEach(button=>
button.onclick=()=>openFollow());
+ root.querySelectorAll('[data-check-dismiss]').forEach(button=>button.onclick=()=>{
+ followCheckReport=null;
+ button.closest('.fcheckreport')?.remove();
+ });
}
/* 查找结果先摆出来由人勾选,不自动登记:发现要联网,结果也可能不止一个,