Repository navigation
nav 首页壁纸默认 Bing 每日壁纸 + 后台来源切换(全站统一) - #24
Merged
todosdev[bot] merged 2 commits intoNov 5, 2026
Merged
Conversation
added 2 commits
November 5, 2026 09:51
缓存键改为同源绝对 URL(裸串在 workerd 会 500);缓存条目 TTL 与客户端 TTL 分层(2 天 vs 到次日零点);只透传 content-type/cache-control;设置未到达时不发探针;补齐契约文档与回归测试。 Co-Authored-By: Claude Code <noreply@anthropic.com> Checkpoint: f4r47QJEYtNgnyRqVLn9D
This was referenced Nov 7, 2026
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.
概述
GET /api/wallpaper/today,直接返回当日 Bing 图字节(免跨域),按北京时间跨日换图。backgroundUrl→ 纯色底#0f172a。改动
worker
worker/src/routes/wallpaper.ts(新增):端点实现。按天 Cache API 缓存(缓存键为同源绝对 URL、含北京时间日期),回源 Bing 官方接口、优先 UHD 变体、失败降接口原图;缓存条目 TTL 与客户端 TTL 分层(条目存 2 天以支撑「昨日回退」,客户端只缓存到次日零点);回源失败回退昨日缓存、再 502;响应头只透传content-type/cache-control。worker/src/index.ts:挂载/api/wallpaper(位于 SPA fallback 之前)。worker/src/types.ts、worker/src/services/site-data.ts:SiteSettingsDto增加wallpaperSource,缺省/脏值统一归一bing。worker/src/routes/admin.ts:SETTING_KEYS加wallpaper_source,PUT /settings严格校验bing|custom,非法值 400。web
web/src/lib/types.ts、web/src/lib/mockDb.ts:SiteSettings加wallpaperSource字段并补齐 mock 与旧库兼容。web/src/components/admin/settings-panels.tsx:新增「壁纸来源」下拉切换(用现有Select控件)。web/src/components/public-page.tsx:按wallpaperSource解析背景来源;站点设置未到达时不发探针;Bing 取图失败回落backgroundUrl→ 纯色底。文档
docs/api-contract.md:补wallpaperSource字段与GET /api/wallpaper/today契约。测试
pnpm test:worker 115 / web 76 全绿。pnpm typecheck、pnpm lint、pnpm format:check、pnpm build全绿。wrangler dev4.152)实测:冷/热路径 200、热路径命中缓存、昨日回退命中、响应头仅content-type/cache-control(无x-msedge-ref/nel/report-to)。