36 lines
1.3 KiB
Swift
36 lines
1.3 KiB
Swift
import SwiftUI
|
|
import Sparkle
|
|
import AppKit
|
|
|
|
final class AppDelegate: NSObject, NSApplicationDelegate {
|
|
static var updater: SPUStandardUpdaterController?
|
|
func applicationDidFinishLaunching(_ notification: Notification) {
|
|
guard let feed = Bundle.main.object(forInfoDictionaryKey: "SUFeedURL") as? String,
|
|
URL(string: feed)?.scheme != nil,
|
|
let key = Bundle.main.object(forInfoDictionaryKey: "SUPublicEDKey") as? String,
|
|
!key.isEmpty else { return }
|
|
Self.updater = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
|
|
}
|
|
}
|
|
|
|
@main
|
|
struct TonuinoManagerApp: App {
|
|
@NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
|
@StateObject private var model = AppModel()
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
ContentView()
|
|
.environmentObject(model)
|
|
.frame(minWidth: 980, minHeight: 640)
|
|
}
|
|
.commands {
|
|
CommandGroup(replacing: .newItem) { }
|
|
CommandGroup(after: .appInfo) {
|
|
Button("Auf Updates prüfen…") { AppDelegate.updater?.checkForUpdates(nil) }
|
|
.disabled(AppDelegate.updater?.updater.canCheckForUpdates != true)
|
|
}
|
|
}
|
|
}
|
|
}
|