Repository navigation
nav 图标前端接入:SiteIcon 改用 /api/icon(引用 #10 契约) - #27
Merged
todosdev[bot] merged 3 commits intoNov 5, 2026
Merged
Conversation
SiteIcon 候选改为 [iconUrl, "/api/icon?url=" + encodeURIComponent(url)],两档都失败回退首字圆(#10 冻结契约);回退进度按候选清单重置,切换搜索引擎时新图标不再被旧失败跳过;补 9 条单测。
按评审意见:候选清单变化时在渲染期复位(React 官方 props→state 模式),A→B→A 不再取回旧进度;img 用 key={src} 换元素 + 当前 src 校验 + 函数式更新,旧请求 error 不会跳过新候选。补 3 条回归测试(A→B→A、手动图标换值、旧 error),测试去掉非空断言(biome 警告回到基线 1 条)。
…6-7a1e-ba05-98e4595e72ad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /api/icon(worker 端解析目标站图标并缓存),删除 Google s2 与目标站裸/favicon.ico两个直连候选,不再依赖第三方图标服务。iconUrl仍然优先,加载失败才回退端点;两档都失败回退首字圆,initialOf/hashColor未动,视觉保持不变。main落地),本分支已合并最新origin/main。Changes
web/src/lib/icons.tsfaviconCandidates()候选改为[iconUrl, "/api/icon?url=" + encodeURIComponent(url)];手动图标、Google s2、裸/favicon.ico的旧三元顺序收敛为两档。web/src/components/site-icon.tsxurl/iconUrl变化(切搜索引擎、改手动图标)时从第一候选重试,A→B→A 来回切换不会取回旧进度。<img key={src}>在候选变化时换元素,onError校验currentTarget的 src 并改用函数式更新,旧请求的 error 不会把新候选跳过。web/test/site-icon.test.tsx(新增)Testing
pnpm test:worker 151/151、web 90/90;pnpm typecheck、pnpm lint(退出 0,27 条均为存量 warning)、pnpm format:check、pnpm build全部通过;上一提交ac94fa8的 CI 全绿,合并origin/main后同套检查复跑通过。wrangler dev,本地 D1/R2)+ 真网络 + 无头 Chrome(1440×900)联调:GitHub 32px ICO、Python 144px PNG 正常显示;example.com返回 404 → 首字圆;手动data:图标直接渲染且不请求端点;页面无 Google / 裸 favicon 直连请求;/api/icon的 200 / 400 / 404 响应与_cache/不可公开读取均与契约一致。