feat(settings): 工作区背景新增「壁纸市场」(Wallhaven SFW 图库浏览/下载/应用) - #626
Open
user-A100 wants to merge 9 commits into
Open
Conversation
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.
Closes #624
功能概述 / What
在 设置 → 外观 → 工作区背景 中新增「壁纸市场」:浏览 Wallhaven 公开图库(
purity=100SFW 强制),点击缩略图即由后端下载、校验并立即应用为当前背景。backgrounds/marketplace.rs(新):搜索(purity=100 硬编码、分类映射 all/general/anime/people→111/100/010/001)、缩略图代理、下载。全部 URL 经 https +wallhaven.cc/子域 白名单校验(拒绝 userinfo),Content-Type 限 jpeg/png/webp,响应体双重上限(搜索 4 MiB / 缩略图 4 MiB / 原图 16 MiB),下载复用既有validate_background+write_background_atomic—— 与本地选图同一条安全路径background_market_search / _asset / _download三组:commands/background.rs的_core+ tauri command、web/handlers/background.rsAxum handler、router/lib.rs 注册,Tauri 与 standalone-server 双模式同构lib/workspace-background-market.tstransport 绑定(camelCase 镜像);useProxiedBackgroundThumb(模块级 asset 缓存 + per-consumer blob URL,镜像宠物市场同款 hook)downloadMarketWorkspaceBackground(后端落盘 → bump 版本戳 → 跨窗口重读盘,与本地选图共用失效广播);workspaceBgSourceUrl「使用中」标记(localStorage,本地图/移除时清除)workspace-background-market-dialog.tsx:搜索(300ms 防抖)+ 分类 + 缩略图网格 + 分页 + 加载/空/错误可重试三态 + 「使用中」徽标;入口为工作区背景区「壁纸市场」按钮AppearanceSettings.workspaceBackground.market.*10 locale 同步(messages.test.ts键集校验通过)设计取舍 / Why
pets/marketplace.rs→ commands → transport):与仓库既有市场类功能同构,无新依赖(reqwest/base64 均已在 Cargo.toml)。backgrounds::MAX_BG_BYTES,市场图与本地选图共享同一张安全网,避免出现第二套上限。th.wallhaven.cc(与宠物市场代理 codex-pets.net 同因)。验证 / How verified
自动化(本机全部实际执行):
cargo test --no-default-features --bin codeg-server --lib✅(含 marketplace 8 个新单测:URL 白名单/分类映射/payload 解析/去窄化)cargo clippy --all-targets --features test-utils -- -D warnings✅、cargo clippy --no-default-features --bin codeg-server --lib -- -D warnings✅cargo check(tauri)与cargo check --no-default-features --bin codeg-server✅pnpm vitest run --maxWorkers=1:397 文件 / 5620 测试全部通过(Task 4/5 两次全量)✅npx tsc --noEmit✅、eslint 对全部改动文件 ✅手动 smoke(桌面 dev 构建)✅:市场打开/搜索/分类/下载应用/「使用中」徽标/分页/本地图覆盖清除标记。
English summary: Adds a "Wallpaper Market" to Settings → Appearance → Workspace Background, backed by the key-free Wallhaven public search API. SFW is hard-coded (
purity=100), all URLs pass an https + wallhaven.cc allowlist, search/asset/download are proxied host-side, and downloads go through the exact same validation + atomic write as a manual background pick. Dual-mode (Tauri + standalone server), 10-locale i18n, full test suite green.