Compare commits
No commits in common. "35de7263e9752be3d8295aea34b6ee5ffa7c8081" and "5960c5f7c8386f65ac649c7352e0628e39064723" have entirely different histories.
35de7263e9
...
5960c5f7c8
@ -2,20 +2,9 @@ import SwiftUI
|
|||||||
import AVFoundation
|
import AVFoundation
|
||||||
import Combine
|
import Combine
|
||||||
import SwiftBricks
|
import SwiftBricks
|
||||||
#if os(macOS)
|
|
||||||
import AppKit
|
|
||||||
|
|
||||||
// 防止关闭所有窗口时退出应用
|
|
||||||
class AppDel: NSObject, NSApplicationDelegate {
|
|
||||||
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { false }
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@main
|
@main
|
||||||
struct MiniPlayerApp: App {
|
struct MiniPlayerApp: App {
|
||||||
#if os(macOS)
|
|
||||||
@NSApplicationDelegateAdaptor(AppDel.self) var appDelegate
|
|
||||||
#endif
|
|
||||||
@StateObject private var bridge = PlayerBridge()
|
@StateObject private var bridge = PlayerBridge()
|
||||||
@StateObject private var engine = BricksEngine()
|
@StateObject private var engine = BricksEngine()
|
||||||
|
|
||||||
|
|||||||
@ -89,11 +89,6 @@ final class PlayerBridge: ObservableObject {
|
|||||||
|
|
||||||
// MARK: - 初始化
|
// MARK: - 初始化
|
||||||
func setup() {
|
func setup() {
|
||||||
#if os(macOS)
|
|
||||||
// 设置为正常 GUI 应用,显示在 Dock 中
|
|
||||||
NSApp.setActivationPolicy(.regular)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
player.volume = volume
|
player.volume = volume
|
||||||
|
|
||||||
setupTimeObserver()
|
setupTimeObserver()
|
||||||
@ -434,19 +429,16 @@ final class PlayerBridge: ObservableObject {
|
|||||||
if let win = playlistWindow, win.isVisible {
|
if let win = playlistWindow, win.isVisible {
|
||||||
win.close(); playlistWindow = nil; return
|
win.close(); playlistWindow = nil; return
|
||||||
}
|
}
|
||||||
let panel = NSPanel(
|
let win = NSWindow(
|
||||||
contentRect: NSRect(x: 0, y: 0, width: 400, height: 500),
|
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))"
|
win.title = "\(L.playlist) (\(queue.count))"
|
||||||
panel.isReleasedWhenClosed = false
|
win.isReleasedWhenClosed = false
|
||||||
panel.isMovableByWindowBackground = true
|
win.center()
|
||||||
panel.hidesOnDeactivate = false
|
win.contentView = NSHostingView(rootView: PlaylistWindowView(bridge: self))
|
||||||
panel.becomesKeyOnlyIfNeeded = true
|
win.makeKeyAndOrderFront(nil)
|
||||||
panel.center()
|
playlistWindow = win
|
||||||
panel.contentView = NSHostingView(rootView: PlaylistWindowView(bridge: self))
|
|
||||||
panel.makeKeyAndOrderFront(NSApp)
|
|
||||||
playlistWindow = panel
|
|
||||||
#else
|
#else
|
||||||
showPlaylistSheet.toggle()
|
showPlaylistSheet.toggle()
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -104,11 +104,9 @@ final class ScreenRecorder: NSObject, AVCaptureFileOutputRecordingDelegate {
|
|||||||
self.fileOutput = output
|
self.fileOutput = output
|
||||||
|
|
||||||
// 请求屏幕录制权限(macOS 10.15+)
|
// 请求屏幕录制权限(macOS 10.15+)
|
||||||
// CGRequestScreenCaptureAccess 在首次调用时触发权限弹窗
|
// CGPreflightScreenCaptureAccess 在首次调用时触发权限弹窗
|
||||||
#if canImport(ScreenCaptureKit)
|
#if canImport(ScreenCaptureKit)
|
||||||
if !CGPreflightScreenCaptureAccess() {
|
CGPreflightScreenCaptureAccess()
|
||||||
CGRequestScreenCaptureAccess()
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user