Repository navigation
feat(desktop): 接入工作台背景图,侧边按钮条弹窗与设置外观共用同一设置 - #1878
Merged
Merged
Conversation
- 用户自选 PNG/JPEG 作为工作台背景,不内置默认图片;图片复制到用户数据目录,重启后恢复 - 右下侧边按钮条打开背景弹窗,设置 → 外观 增加背景行(缩略图、状态、选择/移除、图片可见度) - 淡、中、浓三档遮罩;没有图片时不显示图片可见度 - 打开项目时整窗绘制,面板、外框、编辑区、终端、Git 日志、差异、Markdown 预览透出背景,弹窗与菜单保持实底 - store 增加 WriteFile/Remove;新增功能矩阵 workbench-background-image,更新两条相关记录
TestLogEventsMatchCatalog 增加背景图的三个 operation_failed 操作 (workbench_background、workbench_background_save、workbench_background_remove) 和四个 app.action.performed 动作(workspace.background.open、choose、remove、strength), 确认 Core 目录校验接受这些字段值。
- 选图时在后台读取、校验并解码图片,再在后台写入副本;副本写好后才替换当前背景, 写入失败时提示并保留原背景与原设置 - 移除背景、解码失败时在后台删除副本;启动恢复时在后台读取副本,副本缺失按未选择处理 - 选择、移除、恢复共用序号,过期的解码、写入、删除结果一律丢弃;副本的写入与删除串行执行 - 没有数据目录时不再空指针崩溃,所选图片只显示到退出 - 新增测试:副本写不进去时保留上一张图;副本写入期间移除背景后保持移除且不留副本 - 功能矩阵说明同步更新
xiaoyumuxi
marked this pull request as ready for review
November 14, 2026 03:00
This was referenced Nov 14, 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.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
旧客户端可以在工作台后面放一张自己的图片,Viva 桌面端此前只有右下侧边按钮条上的“背景”按钮,点开是空的工具窗口,设置里也没有入口。本 PR 把这项功能真正接上:侧边按钮条弹窗和 设置 → 外观 两个入口共用同一项设置,图片真实画在工作台后面;按要求不内置任何默认图片,没选图片时两处都显示“未选择背景图片”和“选择图片…”。实现参照 motty 的
internal/workbench/background.go(选图 → 复制到数据目录 → 解码一次 → 整窗画在最底层、上面叠遮罩),文件读写按本仓库规则全部移出窗口线程。改动 / Changes
工作台背景图(
desktop/internal/workbench/workbench_background.go,新增)workbench-background副本(store.WriteFile原子写入),设置只保存原文件名和档位(settings.json的workbenchBackground,omitzero);原文件移动或删除不影响背景。App.backdrop由第一个标签创建并传给后续标签),修改后统一重绘所有工作台和设置窗口。store为 nil)时不再空指针崩溃,所选图片只显示到退出。绘制与透明(工作台)
root.go:有背景时窗口底色改为主题底色乘档位不透明度的遮罩,图片作为 0 层整窗按比例裁切居中绘制(DrawBackdrop)。theme.go:调色板新增Ground(始终不透明的编辑区底色);显示背景时Panel、Editor变为透明,Viva 的弹窗、菜单、卡片、输入框仍用主题实底。project_gradient.go:显示背景时外框(标题栏、侧边按钮条、状态栏)不画实底。Editor/Panel改用Ground:标签拖动和工具窗口拖动的浮层(tabdrag.go、drag.go)、Git 日志与 worktree 的引用标签(gitgraph.go、gitworktree_view.go)、差异块复选框(difftab_view.go)、Markdown 预览目录按钮(markdown_preview.go)、记住的窗口底色(root.go)。侧边按钮条弹窗(
catalog.go、chrome_view.go)chromeState.apply跳过非工具窗口项)。设置 → 外观(
desktop/internal/settingswindow/)CoverRegion)、状态、选择图片…;有图片时显示移除和淡/中/浓选择;窄窗口时改为纵向排列。Options新增WorkbenchBackground、ChooseWorkbenchBackground、RemoveWorkbenchBackground、SetWorkbenchBackgroundStrength;设置窗口在自己的线程加锁读快照,修改投递回工作台线程执行。终端(
desktop/internal/termview/)Look新增Solid:Background可以是透明的(透出背景图),而反色单元、光标下文字、输入法组字区的底色、回应程序的颜色查询以及系统 ANSI 颜色的对比度判断都用不透明的Solid;Solid为零值时取Background,行为与之前相同。Solid: Ground。存储(
desktop/internal/store/store.go)WriteFile(原子替换,Save改为调用它)、Remove(文件不存在视为成功)、Path。日志
workbench_background(选图或恢复失败)、workbench_background_save(副本写入失败)、workbench_background_remove(副本删除失败),以及动作workspace.background.open/choose/remove/strength;均已纳入TestLogEventsMatchCatalog,经 Core 目录校验。界面文案(
shared/i18n/)desktop.workbenchBackground.*中英词条(说明、移除、关闭、图片可见度、淡/中/浓、载入中、状态、失败原因、超过 30 MB、超过 6400 万像素、只支持 PNG 和 JPEG、文件筛选名);标题、“选择图片…”、“未选择背景图片”复用已有词条;已重新生成desktop/internal/i18n/shared.generated.go。功能矩阵(
shared/platform-feature-matrix/features/)workbench-background-image.json:两端 implemented、验证 pending,写明整机验证步骤。editor-wallpaper-overview-ruler.json:说明 Viva 已有背景图、缩略图不画实底,Viva 编辑器没有概览标尺,本项不再单独实现。workbench-islands-appearance.json:删掉验证说明里旧客户端的壁纸检查(Agent 对话、数据库工具栏等已不存在),改为指向workbench-background-image。测试
workbench_background_test.go(新增):选图后弹窗与设置页显示同一状态、整窗绘制与遮罩、档位切换、重启恢复、原图删除后仍可恢复、损坏副本被关闭并删除、超大与不支持的图片报原因且原背景不变、多个标签共用、副本写不进去时保留上一张图、副本写入期间移除后保持移除且不留副本、没有数据目录时不崩溃等。settingswindow/workbench_background_view_test.go(新增):外观卡片的行、缩略图裁切和按钮。termview/look_test.go(新增):透明Background与Solid的分工。store_test.go:WriteFile覆盖写入、Remove删除与重复删除。不在本 PR 范围内 / Out of scope
settings.json仍在窗口线程保存(与现有所有设置项相同的既有写法),本 PR 只把背景图副本的读、写、删移出窗口线程;设置保存的线程归属随 [Feature] 统一 Viva 应用偏好所有权与多窗口发布,避免独立快照继续使用或覆盖旧设置 #1851 一起处理。pending。类型专属:feat
多平台对齐
Lithe 的目标是 macOS 与 Windows 能力对齐。必须选下面一项:
desktop/实现,没有平台分支。platform-specific),理由:范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/<id>.json:新增workbench-background-image.json,两端实现状态 implemented、验证状态 pending(未做整机验证),证据路径、owner、验证动作已填写;同步更新了editor-wallpaper-overview-ruler.json与workbench-islands-appearance.json./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/preview HEAD.artifacts/下生成的矩阵视图统一日志系统 / Structured logging
operationFailedEvent/app.action.performed写法,操作名和动作名经 Core 目录校验(TestLogEventsMatchCatalog用ValidateCatalog: true编码每个新事件);没有print、直接写 stderr 或手写事件 IDdocumentLogError去掉路径,只保留错误码与错误域;文件名只出现在界面状态里node scripts/logging/generate-log-events.mjs --check和node scripts/logging/verify-log-usage.mjs:本仓库当前没有scripts/logging/目录,无法运行;事件校验由上面的TestLogEventsMatchCatalog覆盖,没有新增任何豁免界面文案 / i18n
shared/i18n/补齐 14 条中英词条,运行node scripts/i18n/generate-i18n.mjs并提交生成结果,没有手改生成文件;Go 代码通过生成的i18n.Messages取词条node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,没有放宽脚本或扩大豁免名单逻辑归属 / Logic placement
settings.json性能与内存 / Performance and memory
settings.json的保存仍在窗口线程(既有写法,见“不在本 PR 范围内”)desktop/internal/editor/**、desktop/internal/editorview/**),不需要编辑器基线;没有新增依赖(只用 Go 标准库image/png、image/jpeg)设置 / Settings
插件契约 / Plugin contract
N/A:不涉及插件契约、能力版本、插件函数协议或宿主方法。
发行包与资源 / Bundle and resources
workbench-background由store写在用户数据目录(与settings.json同目录),用户选图时创建、移除或损坏时删除,归工作台所有,不影响代码签名和 Sparkle delta;没有内置默认图片,也没有新增打包资源;已运行./scripts/desktop/verify/verify-runtime-bundle-immutability.sh无用代码与重构 / Dead code and refactoring
panel: true已移除,旧布局中的打开状态被跳过)验证 / Verification
scripts/desktop/desktop-go.sh test ./internal/workbench/ -count=1scripts/desktop/desktop-go.sh test -race -count=3 -run Background ./internal/workbench/scripts/desktop/desktop-go.sh test -run 'Background|Scale' -v ./internal/workbench/scripts/desktop/desktop-go.sh test ./internal/settingswindow/scripts/desktop/desktop-go.sh test ./internal/store/ ./internal/termview/ -count=1scripts/desktop/desktop-go.sh vet ./...gofmt -l(改动文件)node scripts/platform-feature-matrix/generate-platform-feature-matrix.mjs --check./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/preview HEADnode scripts/i18n/generate-i18n.mjs --checknode scripts/i18n/verify-app-language-localization.mjs./scripts/desktop/verify/verify-runtime-bundle-immutability.sh未能执行的检查和原因:
pending。desktop/代码,没有平台分支。scripts/logging/下的两个日志脚本在本仓库不存在,未运行;以TestLogEventsMatchCatalog代替。提交前确认 / Final checks
preview创建,并已合并最新origin/preview;目标分支:preview.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图