-
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad5375e
commit 09cb781
Showing
14 changed files
with
2,931 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// GithubRepositoryProtocol.swift | ||
// OnlySwitch | ||
// | ||
// Created by Jacklandrin on 2022/7/4. | ||
// | ||
|
||
import Foundation | ||
|
||
protocol GitHubRepositoryProtocol { | ||
var latestVersion:String {get} | ||
var downloadURL:String {get} | ||
var isTheNewestVersion: Bool {get} | ||
var downloadCount:Int {get} | ||
var updateHistoryInfo:String {get} | ||
|
||
func checkUpdate(complete:@escaping (Result<Void, Error>) -> Void) | ||
func requestReleases(complete:@escaping (Result<Void, Error>) -> Void) | ||
func downloadDMG(complete:@escaping (Result<String, Error>) -> Void) | ||
func requestShortcutsJson(complete:@escaping (Result<[ShortcutOnMarket], Error>) -> Void) | ||
|
||
} | ||
|
||
extension GitHubRepositoryProtocol { | ||
var myAppPath:String? { | ||
let appBundleID = Bundle.main.infoDictionary?["CFBundleName"] as! String | ||
let paths = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).map(\.path) | ||
let directory = paths.first | ||
let myAppPath = directory?.appendingPathComponent(string: appBundleID) | ||
return myAppPath | ||
} | ||
|
||
func makeRequestURL(host:URLHost = .gitHubAPI, path:EndPointKinds) -> URL? { | ||
var components = URLComponents() | ||
components.scheme = httpsScheme | ||
components.host = host.rawValue | ||
components.path = "/" + path.rawValue | ||
return components.url | ||
} | ||
|
||
} |
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
Oops, something went wrong.