-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce global context and migrate updater controller into
- Loading branch information
1 parent
a7bb785
commit 412c7df
Showing
7 changed files
with
65 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// GlobalContext.swift | ||
// Easydict | ||
// | ||
// Created by 戴藏龙 on 2024/1/25. | ||
// Copyright © 2024 izual. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Sparkle | ||
|
||
@objc class GlobalContext: NSObject { | ||
static let updaterController: SPUStandardUpdaterController = { | ||
class SPUUpdaterHelper: NSObject, SPUUpdaterDelegate { | ||
func feedURLString(for _: SPUUpdater) -> String? { | ||
var feedURLString = "https://raw.githubusercontent.com/tisfeng/Easydict/main/appcast.xml" | ||
#if DEBUG | ||
feedURLString = "http://localhost:8000/appcast.xml" | ||
#endif | ||
return feedURLString | ||
} | ||
} | ||
|
||
class SPUUserDriverHelper: NSObject, SPUStandardUserDriverDelegate { | ||
var supportsGentleScheduledUpdateReminders: Bool { | ||
true | ||
} | ||
} | ||
let userDriverHelper = SPUUserDriverHelper() | ||
let upadterHelper = SPUUpdaterHelper() | ||
// 参考 https://sparkle-project.org/documentation/programmatic-setup/ | ||
// If you want to start the updater manually, pass false to startingUpdater and call .startUpdater() later | ||
// This is where you can also pass an updater delegate if you need one | ||
return SPUStandardUpdaterController( | ||
startingUpdater: true, | ||
updaterDelegate: upadterHelper, | ||
userDriverDelegate: userDriverHelper | ||
) | ||
}() | ||
|
||
@objc class func getUpdaterController() -> SPUStandardUpdaterController { | ||
updaterController | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters