Add GitHub update checker and installer

This commit is contained in:
世界
2026-03-30 23:02:42 +08:00
parent 6b790c7a80
commit 63d1d0fe3f
15 changed files with 1663 additions and 2 deletions
+26
View File
@@ -0,0 +1,26 @@
import Foundation
public enum UpdateTrack: String, Codable, CaseIterable {
case stable
case beta
public static var defaultForCurrentBuild: Self {
Bundle.main.version.contains("-") ? .beta : .stable
}
public static func resolved(from rawValue: String) -> Self {
guard !rawValue.isEmpty else {
return defaultForCurrentBuild
}
return Self(rawValue: rawValue) ?? defaultForCurrentBuild
}
public func allows(_ updateInfo: UpdateInfo) -> Bool {
switch self {
case .stable:
return !updateInfo.isPrerelease
case .beta:
return true
}
}
}