From d81825ba8c0f46ae3896b64db4f5067c364887eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=81=E5=86=9C=E9=98=BF=E6=A5=A0?= Date: Tue, 3 Nov 2026 13:20:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(settings):=20=E4=BF=AE=E5=A4=8D=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E5=88=87=E6=8D=A2=E5=90=8E=E7=AA=97=E5=8F=A3=E4=B8=8E?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E6=B7=B1=E6=B5=85=E6=B7=B7=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/architecture.md | 1 + docs/unified-panel-validation.md | 8 ++++++++ kymo/Features/Settings/AppearanceSettingsView.swift | 12 ++++-------- kymo/UI/Components/AppearanceStyle.swift | 4 ++++ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index a9b2b62..4a49d89 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -68,6 +68,7 @@ GPU 通过 IOAccelerator 的 PerformanceStatistics / Device Utilization % 读取 - 旧 MetricRow / HoverDetailPresenter / DetailPlacement 与旧迷你趋势源码暂保留作迁移参照,正式面板已无调用;待真实 UI 回归后在 P6 清理并同步其历史检查程序,不能把源码存在理解为仍有双套交互。 - `AppearancePreferences` 仅依赖 Foundation / Observation,持久化外观、系统/六种预设/自选 RGB 强调色。UI 层 `AppearanceStyle` 将偏好映射为明确的深/浅色及窗口级 NSAppearance / Color。跟随系统从全局偏好 AppleInterfaceStyle 独立解析,监听系统主题通知及 NSApp effectiveAppearance 变化后刷新;为 SwiftUI 同时提供非 nil 的 preferredColorScheme 与 colorScheme 环境,避免返回 nil 和失焦后重新继承窗口残留模式。用户持久化值仍为 system,App 全局 appearance 不被修改。该系统偏好键/主题通知属于平台约定,系统动态切换仍需实机验证;外观覆盖作用于面板与设置,不作用于菜单栏标签。 - 设置页外观选择使用 `GlassEffectContainer`:外层为系统液态玻璃胶囊,选中态以共享 `glassEffectID` / `matchedGeometry` 的独立玻璃胶囊在三个选项间移动;遵循减少动态效果,其他表单仍使用系统分组与原生控件。 +- Settings 场景的 NavigationSplitView / Form 原生承载层在切换主题时可能保留旧环境,导致标题栏与表单深浅混用。设置页单独启用 AppearanceStyle.refreshContentOnChange,以解析后的 light/dark 为内容身份刷新承载子树;页面选择、偏好与色板控制器状态仍保留在外层 AppearanceSettingsView。跟随系统解析出新的主题时采用相同路径;面板不启用重建。选择器动画限定在控件内部,不用 withAnimation 包裹整个偏好变更;主题切换会重建控件,原有跨主题玻璃位移动画不保证连续。 - `LanguagePreferences` 独立持久化 system / zh-Hans / zh-Hant / en,仅依赖 Foundation / Observation。App 将同一 locale 注入面板与设置,切换即时生效;系统模式按 Locale.preferredLanguages 匹配已支持语言,无法匹配回退 en,不修改 AppleLanguages。外侧详情的独立 NSHostingView 显式转发 locale;UI 的 AppLocalization 为原生窗口标题与色块辅助标签查找对应 lproj,避免其沿用进程启动语言。系统菜单与 NSColorPanel 的系统文案由 macOS 管理。语言自称保留原文。 - App 注入同一个偏好仓库,注册独立 Settings 场景;设置采用 `NavigationSplitView` 侧边栏与系统式分组 `Form`,分为外观、语言、监控、关于。窗口、侧边栏和控件遵循 macOS 设置页的原生材质与层级,不在内容区叠加整块自绘液态玻璃卡片;关于页展示品牌图标和 Bundle 实际版本,不写死版本号。 - App 持有一个与 UI 无关的 `SettingsPresentation` 请求状态,并向 MenuBar 与 Settings 注入同一实例。菜单入口先切换 `.regular`,递增请求并调用 `openSettings`;设置窗口观察器在请求变化时取消旧任务、等待 SwiftUI 排序后激活应用、将窗口置前并清除最小化。只使用普通窗口层级,不永久置顶;活动应用通知补充处理激活竞态,隐藏后重开与最小化恢复走同一路径。窗口关闭时恢复 `.accessory`,保留 `LSUIElement=true` 的默认无 Dock 行为。 diff --git a/docs/unified-panel-validation.md b/docs/unified-panel-validation.md index 9713ac6..180172f 100644 --- a/docs/unified-panel-validation.md +++ b/docs/unified-panel-validation.md @@ -130,3 +130,11 @@ Debug / Release 首版构建通过;不能据此标记 P1、P3、P4 退出条 通过:Debug 构建;PanelAssetChecks 从编译后的实际应用读取深浅资源,检查面板/卡片/指标 alpha、CPU 序列色相差至少 36°、指标/序列对卡片图形对比度至少 3:1。原来的 RGB 欧氏距离阈值不能直接表达新调色的色相分离,故改为环形色相间隔并新增实际亮度对比度校验。 使用实际 ResourceCard、PanelTrendChart、MetricProgressBar 和编译资源,通过 ImageRenderer 渲染固定样本的两排六卡片,深浅两种模式确认实色层级、明亮强调色与复合曲线区分。该样例使用简化文本/固定样本,不是完整 MenuPanelView 截图,不证明正式 NSPanel 悬浮事件或真实数据;本轮未重启用户应用。临时渲染程序、图片、缓存及构建产物清理,用户既有本地化改动未纳入提交。 + +### 设置窗口深浅混用修复(2026-11-03) + +在隔离测试包中使用与正式入口相同的 NSHostingSceneRepresentation + Settings 和实际 AppearanceSettingsView,原生点击深色→浅色,复现标题栏/背景变浅、侧栏文字与 Form 仍深色的用户截图现象。单独取消全局动画、在两栏重复注入外观均不能解决;按主题刷新分栏承载子树后消除。正式实现由 AppearanceStyle 提供默认关闭的 refreshContentOnChange,仅设置页开启,以解析后的 light/dark 为身份,覆盖手动选择与跟随系统解析变化。外层页面选择/偏好仓库保持不变,主题切换时原生控件及临时滚动/焦点可能重新建立。 + +通过:最终 Debug 构建;既有 PresentationChecks 的显式/系统窗口外观重置、独立系统主题解析及原生色板检查。最终源码隔离 Settings 窗口中,真实点击深→浅、浅→深、深→跟随系统(当前系统为浅色),截图确认窗口外壳、侧栏文字、表单与选择器一致;切到监控页确认表单仍为浅色。测试包未打包本地化资源,截图展示键名,不用它评价正式中文排版。未修改系统主题来测试系统通知、未重复完整多屏/失焦矩阵,未重启用户主应用。 + +测试前记录并保留用户 Xcode 副本 PID 25966。仅退出本轮隔离测试包,注销并清理临时应用、独立偏好 suite、编译缓存与产物;工作区已有本地化改动不纳入提交。 diff --git a/kymo/Features/Settings/AppearanceSettingsView.swift b/kymo/Features/Settings/AppearanceSettingsView.swift index d63d75b..149901f 100644 --- a/kymo/Features/Settings/AppearanceSettingsView.swift +++ b/kymo/Features/Settings/AppearanceSettingsView.swift @@ -46,7 +46,7 @@ struct AppearanceSettingsView: View { } .onChange(of: selection) { _, _ in colorPicker.close() } .frame(minWidth: 720, idealWidth: 780, minHeight: 460, idealHeight: 540) - .modifier(AppearanceStyle(preferences: preferences)) + .modifier(AppearanceStyle(preferences: preferences, refreshContentOnChange: true)) } private var selectedPage: SettingsPage { selection ?? .appearance } @@ -164,13 +164,8 @@ private struct LiquidAppearancePicker: View { HStack(spacing: 4) { ForEach(AppAppearance.allCases) { appearance in Button { - if reduceMotion { - selection = appearance - } else { - withAnimation(.smooth(duration: 0.24)) { - selection = appearance - } - } + // Theme changes must not animate the native split view / Form hierarchy. + selection = appearance } label: { Label(appearance.title, systemImage: appearance.symbol) .labelStyle(.titleAndIcon) @@ -196,6 +191,7 @@ private struct LiquidAppearancePicker: View { .padding(4) .glassEffect(.regular, in: .capsule) } + .animation(reduceMotion ? nil : .smooth(duration: 0.24), value: selection) .accessibilityElement(children: .contain) .accessibilityLabel(Text("appearance.title")) } diff --git a/kymo/UI/Components/AppearanceStyle.swift b/kymo/UI/Components/AppearanceStyle.swift index 704b913..2a9d19e 100644 --- a/kymo/UI/Components/AppearanceStyle.swift +++ b/kymo/UI/Components/AppearanceStyle.swift @@ -33,11 +33,15 @@ extension AppearancePreferences { struct AppearanceStyle: ViewModifier { let preferences: AppearancePreferences + var refreshContentOnChange = false @State private var system = SystemAppearanceObserver() private var resolved: AppAppearance { preferences.appearance.resolved(systemIsDark: system.isDark) } private var scheme: ColorScheme { resolved == .dark ? .dark : .light } func body(content: Content) -> some View { content + // Settings split-view hosts can retain their previous native appearance. + // Keep state in the owning view, but replace the hosted subtree on a resolved theme change. + .id(refreshContentOnChange ? resolved : nil) .background(WindowAppearanceBridge(choice: resolved)) .preferredColorScheme(scheme) .environment(\.colorScheme, scheme)