From 5c8b6ed1369a71ef9a1aaba66920a55b83feea77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=81=E5=86=9C=E9=98=BF=E6=A5=A0?= Date: Fri, 30 Oct 2026 16:13:03 +0800 Subject: [PATCH] =?UTF-8?q?style(menubar):=20=E5=B0=86=E5=BA=95=E9=83=A8?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=94=B9=E4=B8=BA=E4=B8=80=E4=BD=93=E5=BC=8F?= =?UTF-8?q?=E6=B6=B2=E6=80=81=E7=8E=BB=E7=92=83=E8=83=B6=E5=9B=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/architecture.md | 4 +- kymo/Features/MenuBar/MenuPanelView.swift | 72 ++++++++++++++--------- 2 files changed, 47 insertions(+), 29 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index 870f23b..9ce0021 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -146,6 +146,8 @@ App 持有进程级 `KeepAwakeService`(Core/Services,MainActor + Observable 状态不持久化,重启默认关闭;关闭面板、暂停资源采样均不影响已开启的保持唤醒,无额外定时器、辅助进程或权限变更。主动锁屏、主动睡眠、合盖、低电量保护与管理策略仍由系统决定;独立屏保/自动锁定策略的实际行为需在用户环境验收,不以电源断言创建成功替代锁屏实测。 -面板底部四个按钮统一透明背景与圆角矩形细边框,咖啡杯开启时使用当前强调色,并提供三语帮助及无障碍开关状态。 +面板底部四个按钮置于一个原生 `.glassEffect(.regular, in: .capsule)` 液态玻璃胶囊内,各按钮采用圆形悬停/按压反馈,退出按钮前有分隔线;咖啡杯开启时使用当前强调色,并提供三语帮助及无障碍开关状态。 2026-10-30 验证:Debug 构建通过;独立核心检查在普通进程与带主应用沙盒权限的临时 .app 中均通过,实际查询本进程断言,覆盖默认关闭、连续三次开关、开启后两类断言存在、关闭/服务销毁后消失。CLI 检查器直接加沙盒签名会在 libsecinit 初始化阶段退出,改用完整 .app 包后通过,未更改产品权限。当前没有 Xcode 测试 Target。UI 自动化 getApp 本轮构建超时;本轮仅退出自动化启动的测试副本,保留用户 Xcode 进程。底部实际视觉、关闭面板后长时间空闲不锁屏/息屏以及关闭开关后恢复系统策略,待用户验收。 + +底部液态玻璃样式调整:Debug 构建通过;实际面板中的玻璃质感及悬停视觉待用户重新运行验收。 diff --git a/kymo/Features/MenuBar/MenuPanelView.swift b/kymo/Features/MenuBar/MenuPanelView.swift index da920fc..0b7aea5 100644 --- a/kymo/Features/MenuBar/MenuPanelView.swift +++ b/kymo/Features/MenuBar/MenuPanelView.swift @@ -196,29 +196,34 @@ struct MenuPanelView: View { .font(.system(size: 9)).foregroundStyle(.tertiary) } Spacer() - Button { keepAwake.toggle() } label: { - Image(systemName: keepAwake.isEnabled ? "cup.and.saucer.fill" : "cup.and.saucer") - .frame(width: 20, height: 20) - .foregroundStyle(keepAwake.isEnabled ? preferences.tintColor : Color.primary) + HStack(spacing: 2) { + Button { keepAwake.toggle() } label: { + Image(systemName: keepAwake.isEnabled ? "cup.and.saucer.fill" : "cup.and.saucer") + .frame(width: 20, height: 20) + .foregroundStyle(keepAwake.isEnabled ? preferences.tintColor : Color.primary) + } + .help(keepAwake.didFail ? Text("awake.failed") : (keepAwake.isEnabled ? Text("awake.disable") : Text("awake.enable"))) + .accessibilityLabel(keepAwake.isEnabled ? Text("awake.disable") : Text("awake.enable")) + .accessibilityValue(keepAwake.isEnabled ? Text("awake.on") : Text("awake.off")) + Button { metrics.togglePause() } label: { + Image(systemName: metrics.isPaused ? "play.fill" : "pause.fill").frame(width: 20, height: 20) + } + .help(metrics.isPaused ? Text("action.resume") : Text("action.pause")) + .accessibilityLabel(metrics.isPaused ? Text("action.resume") : Text("action.pause")) + Button { NSApp.activate(); openSettings() } label: { + Image(systemName: "gearshape").frame(width: 20, height: 20) + } + .help(Text("action.settings")).accessibilityLabel(Text("action.settings")) + Divider().frame(height: 18).padding(.horizontal, 3) + Button { NSApp.terminate(nil) } label: { + Image(systemName: "power").frame(width: 20, height: 20) + } + .help(Text("action.quit")).accessibilityLabel(Text("action.quit")) } - .help(keepAwake.didFail ? Text("awake.failed") : (keepAwake.isEnabled ? Text("awake.disable") : Text("awake.enable"))) - .accessibilityLabel(keepAwake.isEnabled ? Text("awake.disable") : Text("awake.enable")) - .accessibilityValue(keepAwake.isEnabled ? Text("awake.on") : Text("awake.off")) - Button { metrics.togglePause() } label: { - Image(systemName: metrics.isPaused ? "play.fill" : "pause.fill").frame(width: 20, height: 20) - } - .help(metrics.isPaused ? Text("action.resume") : Text("action.pause")) - .accessibilityLabel(metrics.isPaused ? Text("action.resume") : Text("action.pause")) - Button { NSApp.activate(); openSettings() } label: { - Image(systemName: "gearshape").frame(width: 20, height: 20) - } - .help(Text("action.settings")).accessibilityLabel(Text("action.settings")) - Button { NSApp.terminate(nil) } label: { - Image(systemName: "power").frame(width: 20, height: 20) - } - .help(Text("action.quit")).accessibilityLabel(Text("action.quit")) + .buttonStyle(FooterButtonStyle()) + .padding(4) + .glassEffect(.regular, in: .capsule) } - .buttonStyle(FooterButtonStyle()) .controlSize(.small) .padding(.horizontal, 8).padding(.vertical, 6) } @@ -227,13 +232,24 @@ struct MenuPanelView: View { private struct FooterButtonStyle: ButtonStyle { func makeBody(configuration: Configuration) -> some View { - configuration.label - .padding(.horizontal, 9).padding(.vertical, 6) - .contentShape(RoundedRectangle(cornerRadius: 6)) - .overlay { - RoundedRectangle(cornerRadius: 6) - .strokeBorder(.primary.opacity(configuration.isPressed ? 0.5 : 0.18), lineWidth: 1) + FooterButtonBody(isPressed: configuration.isPressed) { + configuration.label + } + } +} + +private struct FooterButtonBody: View { + let isPressed: Bool + @ViewBuilder var content: () -> Content + @State private var isHovered = false + + var body: some View { + content() + .frame(width: 34, height: 34) + .background { + Circle().fill(.primary.opacity(isPressed ? 0.16 : (isHovered ? 0.08 : 0))) } - .opacity(configuration.isPressed ? 0.6 : 1) + .contentShape(Circle()) + .onHover { isHovered = $0 } } }