From 8f7d62d0cc71566d8d9adead8dbf82a3b756b765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E5=B7=9D=E7=99=BD=E6=B5=AA?= <1679659@qq.com> Date: Thu, 3 Dec 2026 22:22:02 -0700 Subject: [PATCH] refactor(plugin): drop the theme sounds field The host never played these files. A theme with an interactive script can play its own sounds, so a second way is not needed. Old manifests still load and get the usual notice about a field the host does not know. Co-Authored-By: Claude Opus 5.5 --- changes/theme-sounds-removed.json | 9 +++++++++ docs/plugin-architecture.md | 2 +- frontend/wailsjs/go/models.ts | 2 -- internal/plugin/theme_css.go | 5 ----- internal/plugin/types.go | 1 - 5 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 changes/theme-sounds-removed.json diff --git a/changes/theme-sounds-removed.json b/changes/theme-sounds-removed.json new file mode 100644 index 0000000..897579c --- /dev/null +++ b/changes/theme-sounds-removed.json @@ -0,0 +1,9 @@ +{ + "group": "removals", + "order": 0, + "authors": [ + "Nwflower" + ], + "zh": "主题清单不再支持从未生效的 `sounds` 字段。带交互脚本的主题可以自行播放提示音。", + "en": "Theme manifests no longer accept the `sounds` field, which never took effect. Themes with an interactive script can play their own sounds." +} diff --git a/docs/plugin-architecture.md b/docs/plugin-architecture.md index a3e520f..195638c 100644 --- a/docs/plugin-architecture.md +++ b/docs/plugin-architecture.md @@ -50,7 +50,7 @@ Sidecar 的控制台 Host API 只接受 VM 引用,不接受 QMP 套接字或 V ## 主题、面板桥接与契约演进 -宿主内置浅色与深色外观,同时提供三档主题扩展能力:第一档通过种子色与派生规则生成表面、文字和边框色阶,支持替换包内字体、单色图标、品牌标志与事件提示音;第二档提供面向公开部件类名(`rg-p-*`)与只读状态属性(`data-*`)的样式表及槽位/全窗图层状态装饰,由宿主锁定层叠顺序并清洗外部链接,且始终保护标题栏拖拽区、键盘焦点环与最小点击热区;第三档通过稳定的 `contributes.themes[].uiScript` 字段声明交互脚本,仅对获批 `ui:script` 高危权限的主题按需加载前端交互接口。交互脚本运行在主窗口前端环境并共享页面 DOM(并非隔离沙盒),加载前宿主会自动收起桌面底层绑定全局对象。 +宿主内置浅色与深色外观,同时提供三档主题扩展能力:第一档通过种子色与派生规则生成表面、文字和边框色阶,支持替换包内字体、单色图标与品牌标志;第二档提供面向公开部件类名(`rg-p-*`)与只读状态属性(`data-*`)的样式表及槽位/全窗图层状态装饰,由宿主锁定层叠顺序并清洗外部链接,且始终保护标题栏拖拽区、键盘焦点环与最小点击热区;第三档通过稳定的 `contributes.themes[].uiScript` 字段声明交互脚本,仅对获批 `ui:script` 高危权限的主题按需加载前端交互接口,提示音也由交互脚本自行播放。交互脚本运行在主窗口前端环境并共享页面 DOM(并非隔离沙盒),加载前宿主会自动收起桌面底层绑定全局对象。 已激活的外部主题在重启客户端和升级插件后自动保留,并在脚本变更重新批准后带版本哈希参数重载;仅停用或卸载所属主题插件时回退内置默认主题并清空当前配色方案,安全模式或命令行停用无关插件不会影响当前主题。从市场安装并启用主题插件时,仅当当前仍处于内置默认主题才自动切换为该插件的首个主题,不覆盖用户已选的其他外部主题。 diff --git a/frontend/wailsjs/go/models.ts b/frontend/wailsjs/go/models.ts index 401d003..4c8b605 100644 --- a/frontend/wailsjs/go/models.ts +++ b/frontend/wailsjs/go/models.ts @@ -1799,7 +1799,6 @@ export namespace plugin { icons?: Record; brandMark?: string; background?: string; - sounds?: Record; stylesheet?: string; decorations?: ThemeDecoration[]; uiScript?: string; @@ -1825,7 +1824,6 @@ export namespace plugin { this.icons = source["icons"]; this.brandMark = source["brandMark"]; this.background = source["background"]; - this.sounds = source["sounds"]; this.stylesheet = source["stylesheet"]; this.decorations = this.convertValues(source["decorations"], ThemeDecoration); this.uiScript = source["uiScript"]; diff --git a/internal/plugin/theme_css.go b/internal/plugin/theme_css.go index b50f1a8..9f73484 100644 --- a/internal/plugin/theme_css.go +++ b/internal/plugin/theme_css.go @@ -453,11 +453,6 @@ func ValidateThemeContribution(th ThemeContribution, rootDir string) error { return fmt.Errorf("theme icon %q (%q): %w", k, asset, err) } } - for k, asset := range th.Sounds { - if err := validateSafeManifestAsset(asset, rootDir); err != nil { - return fmt.Errorf("theme sound %q (%q): %w", k, asset, err) - } - } for _, dec := range th.Decorations { for _, st := range dec.States { if st.Asset != "" { diff --git a/internal/plugin/types.go b/internal/plugin/types.go index 4ab1ae1..3d2d683 100644 --- a/internal/plugin/types.go +++ b/internal/plugin/types.go @@ -358,7 +358,6 @@ type ThemeContribution struct { Icons map[string]string `json:"icons,omitempty"` BrandMark string `json:"brandMark,omitempty"` Background string `json:"background,omitempty"` - Sounds map[string]string `json:"sounds,omitempty"` Stylesheet string `json:"stylesheet,omitempty"` // relative path inside package Decorations []ThemeDecoration `json:"decorations,omitempty"` UIScript string `json:"uiScript,omitempty"` // requires ui:script