Compare commits

..

No commits in common. "35de7263e9752be3d8295aea34b6ee5ffa7c8081" and "5960c5f7c8386f65ac649c7352e0628e39064723" have entirely different histories.

3 changed files with 10 additions and 31 deletions

View File

@ -2,20 +2,9 @@ import SwiftUI
import AVFoundation
import Combine
import SwiftBricks
#if os(macOS)
import AppKit
// 防止关闭所有窗口时退出应用
class AppDel: NSObject, NSApplicationDelegate {
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { false }
}
#endif
@main
struct MiniPlayerApp: App {
#if os(macOS)
@NSApplicationDelegateAdaptor(AppDel.self) var appDelegate
#endif
@StateObject private var bridge = PlayerBridge()
@StateObject private var engine = BricksEngine()

View File

@ -89,11 +89,6 @@ final class PlayerBridge: ObservableObject {
// MARK: - 初始化
func setup() {
#if os(macOS)
// 设置为正常 GUI 应用,显示在 Dock 中
NSApp.setActivationPolicy(.regular)
#endif
player.volume = volume
setupTimeObserver()
@ -434,19 +429,16 @@ final class PlayerBridge: ObservableObject {
if let win = playlistWindow, win.isVisible {
win.close(); playlistWindow = nil; return
}
let panel = NSPanel(
let win = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 400, height: 500),
styleMask: [.titled, .closable, .resizable, .utilityWindow], backing: .buffered, defer: false
styleMask: [.titled, .closable, .resizable], backing: .buffered, defer: false
)
panel.title = "\(L.playlist) (\(queue.count))"
panel.isReleasedWhenClosed = false
panel.isMovableByWindowBackground = true
panel.hidesOnDeactivate = false
panel.becomesKeyOnlyIfNeeded = true
panel.center()
panel.contentView = NSHostingView(rootView: PlaylistWindowView(bridge: self))
panel.makeKeyAndOrderFront(NSApp)
playlistWindow = panel
win.title = "\(L.playlist) (\(queue.count))"
win.isReleasedWhenClosed = false
win.center()
win.contentView = NSHostingView(rootView: PlaylistWindowView(bridge: self))
win.makeKeyAndOrderFront(nil)
playlistWindow = win
#else
showPlaylistSheet.toggle()
#endif

View File

@ -104,11 +104,9 @@ final class ScreenRecorder: NSObject, AVCaptureFileOutputRecordingDelegate {
self.fileOutput = output
// 请求屏幕录制权限(macOS 10.15+)
// CGRequestScreenCaptureAccess 在首次调用时触发权限弹窗
// CGPreflightScreenCaptureAccess 在首次调用时触发权限弹窗
#if canImport(ScreenCaptureKit)
if !CGPreflightScreenCaptureAccess() {
CGRequestScreenCaptureAccess()
}
CGPreflightScreenCaptureAccess()
#endif
return true