Finish independent macOS version

This commit is contained in:
世界
2023-07-25 14:04:13 +08:00
parent 12bf02070e
commit 486a685bb5
12 changed files with 147 additions and 98 deletions
+5 -18
View File
@@ -20,33 +20,20 @@ open class ApplicationDelegate: NSObject, NSApplicationDelegate {
}
Task.detached {
do {
if Variant.useSystemExtension {
if await SystemExtension.isInstalled() {
if let result = try await SystemExtension.install() {
if result == .willCompleteAfterReboot {
return
}
try ProfileUpdateTask.setup()
if launchedAsLogInItem {
if SharedPreferences.startedByUser {
if let profile = try await ExtensionProfile.load() {
try await profile.start()
}
}
}
try await self.postStart(launchedAsLogInItem)
} catch {
NSLog("application setup error: \(error.localizedDescription)")
}
}
}
private func postStart(_ launchedAsLogInItem: Bool) async throws {
try ProfileUpdateTask.setup()
if launchedAsLogInItem {
if SharedPreferences.startedByUser {
if let profile = try await ExtensionProfile.load() {
try await profile.start()
}
}
}
}
public func applicationShouldTerminateAfterLastWindowClosed(_: NSApplication) -> Bool {
!SharedPreferences.menuBarExtraInBackground
}