32 lines
1.0 KiB
Swift
32 lines
1.0 KiB
Swift
import SwiftUI
|
|
|
|
@main
|
|
struct MiniPlayerApp: App {
|
|
@StateObject private var engine = PlayerEngine()
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
ContentView()
|
|
.environmentObject(engine)
|
|
}
|
|
#if os(macOS)
|
|
.commands {
|
|
CommandGroup(replacing: .newItem) {}
|
|
CommandMenu("播放") {
|
|
Button("下一个") { engine.playNext() }
|
|
.keyboardShortcut(.rightArrow, modifiers: [.command])
|
|
Button("上一个") { engine.playPrevious() }
|
|
.keyboardShortcut(.leftArrow, modifiers: [.command])
|
|
Divider()
|
|
Button("全屏") { engine.toggleFullscreen() }
|
|
.keyboardShortcut("f", modifiers: [.command])
|
|
Divider()
|
|
Button("循环: 单曲") { engine.repeatMode = .single }
|
|
Button("循环: 列表") { engine.repeatMode = .all }
|
|
Button("循环: 关闭") { engine.repeatMode = .none }
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
}
|