AppDelegate // Manage Update Info URL internally.
This commit is contained in:
parent
0142258f34
commit
a56b55125a
|
@ -20,6 +20,19 @@ public class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCen
|
|||
private var folderMonitor = FolderMonitor(
|
||||
url: URL(fileURLWithPath: LMMgr.dataFolderPath(isDefaultFolder: false))
|
||||
)
|
||||
|
||||
public static var updateInfoSourceURL: URL? {
|
||||
guard let urlText = Bundle.main.infoDictionary?["UpdateInfoEndpoint"] as? String else {
|
||||
NSLog("vChewingDebug: Fatal error: Info.plist wrecked. It needs to have correct 'UpdateInfoEndpoint' value.")
|
||||
return nil
|
||||
}
|
||||
return .init(string: urlText)
|
||||
}
|
||||
|
||||
public func checkUpdate(forced: Bool) {
|
||||
guard let url = Self.updateInfoSourceURL else { return }
|
||||
UpdateSputnik.shared.checkForUpdate(forced: forced, url: url)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private Functions
|
||||
|
@ -80,7 +93,7 @@ public extension AppDelegate {
|
|||
|
||||
// 只要使用者沒有勾選檢查更新、沒有主動做出要檢查更新的操作,就不要檢查更新。
|
||||
if PrefMgr.shared.checkUpdateAutomatically {
|
||||
UpdateSputnik.shared.checkForUpdate(forced: false, url: kUpdateInfoSourceURL)
|
||||
checkUpdate(forced: false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -318,7 +318,7 @@ public extension SessionCtl {
|
|||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
UpdateSputnik.shared.checkForUpdate(forced: false, url: kUpdateInfoSourceURL)
|
||||
AppDelegate.shared.checkUpdate(forced: false)
|
||||
AppDelegate.shared.checkMemoryUsage()
|
||||
}
|
||||
|
||||
|
|
|
@ -373,7 +373,7 @@ public extension SessionCtl {
|
|||
}
|
||||
|
||||
@objc func checkForUpdate(_: Any? = nil) {
|
||||
UpdateSputnik.shared.checkForUpdate(forced: true, url: kUpdateInfoSourceURL)
|
||||
AppDelegate.shared.checkUpdate(forced: true)
|
||||
}
|
||||
|
||||
@objc func openUserDataFolder(_: Any? = nil) {
|
||||
|
|
|
@ -57,16 +57,7 @@ else {
|
|||
exit(-1)
|
||||
}
|
||||
|
||||
guard let mainBundleInfoDict = Bundle.main.infoDictionary,
|
||||
let strUpdateInfoSource = mainBundleInfoDict["UpdateInfoEndpoint"] as? String,
|
||||
let urlUpdateInfoSource = URL(string: strUpdateInfoSource)
|
||||
else {
|
||||
NSLog("vChewingDebug: Fatal error: Info.plist wrecked. It needs to have correct 'UpdateInfoEndpoint' value.")
|
||||
exit(-1)
|
||||
}
|
||||
|
||||
public let theServer = server
|
||||
public let kUpdateInfoSourceURL = urlUpdateInfoSource
|
||||
|
||||
NSApplication.shared.delegate = AppDelegate.shared
|
||||
_ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv)
|
||||
|
|
Loading…
Reference in New Issue