diff --git a/Sources/MiniPlayerApp.swift b/Sources/MiniPlayerApp.swift index a068fa4..cdf62e6 100644 --- a/Sources/MiniPlayerApp.swift +++ b/Sources/MiniPlayerApp.swift @@ -319,18 +319,35 @@ struct PlayerContentView: View { } } .onAppear { - // 初始状态:标题随toolbar一起隐藏 - NSApplication.shared.windows.first?.titleVisibility = .hidden + // 初始状态:标题栏完全隐藏 + if let win = NSApplication.shared.windows.first { + win.titleVisibility = .hidden + win.titlebarAppearsTransparent = true + } } .onChange(of: showToolbar) { _, newValue in - // 同步控制窗口标题的显示/隐藏(与toolbar联动) - NSApplication.shared.windows.first?.titleVisibility = newValue ? .visible : .hidden if newValue { resetHideTimer() } else { hideTimer?.invalidate() } } + .overlay(alignment: .top) { + // 标题栏悬停检测:鼠标进入显示标题,退出隐藏 + Color.clear + .frame(height: 28) + .contentShape(Rectangle()) + .onHover { hovering in + let win = NSApplication.shared.windows.first + if hovering { + win?.titleVisibility = .visible + win?.titlebarAppearsTransparent = false + } else { + win?.titleVisibility = .hidden + win?.titlebarAppearsTransparent = true + } + } + } .onDisappear { hideTimer?.invalidate() }