IMEApp // Fix .appVersionLabel().
This commit is contained in:
parent
34a6f036b5
commit
417786dca0
|
@ -77,29 +77,41 @@ public enum IMEApp {
|
||||||
// MARK: - 獲取輸入法的版本以及建置編號
|
// MARK: - 獲取輸入法的版本以及建置編號
|
||||||
|
|
||||||
public static let appVersionLabel: String = {
|
public static let appVersionLabel: String = {
|
||||||
let maybeStrDate: String? = {
|
let maybeDateModified: Date? = {
|
||||||
guard let executableURL = Bundle.main.executableURL,
|
guard let executableURL = Bundle.main.executableURL,
|
||||||
let infoDate = (try? executableURL.resourceValues(forKeys: [.creationDateKey]))?.creationDate
|
let infoDate = (try? executableURL.resourceValues(forKeys: [.contentModificationDateKey]))?.contentModificationDate
|
||||||
else {
|
else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
return infoDate
|
||||||
|
}()
|
||||||
|
|
||||||
|
func dateStringTag(date givenDate: Date) -> String {
|
||||||
let dateFormatter = DateFormatter()
|
let dateFormatter = DateFormatter()
|
||||||
dateFormatter.dateFormat = "yyyyMMdd.HHmm"
|
dateFormatter.dateFormat = "yyyyMMdd.HHmm"
|
||||||
dateFormatter.timeZone = .init(secondsFromGMT: +28800) ?? .current
|
dateFormatter.timeZone = .init(secondsFromGMT: +28800) ?? .current
|
||||||
let strDate = dateFormatter.string(from: infoDate)
|
let strDate = dateFormatter.string(from: givenDate)
|
||||||
return strDate
|
return strDate
|
||||||
}()
|
}
|
||||||
|
|
||||||
guard
|
guard
|
||||||
let intBuild = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as? String,
|
let intBuild = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as? String,
|
||||||
let strVer = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String,
|
let strVer = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
|
||||||
let strDate = maybeStrDate
|
|
||||||
else {
|
else {
|
||||||
return "1.14.514 - 19190810"
|
return "1.14.514 - 19190810"
|
||||||
}
|
}
|
||||||
|
|
||||||
return "\(strVer) Build \(intBuild) - \(strDate)"
|
var theResults = ["\(strVer) Build \(intBuild)"]
|
||||||
|
|
||||||
|
if let theDate = Bundle.main.getCodeSignedDate() {
|
||||||
|
theResults.append(dateStringTag(date: theDate))
|
||||||
|
} else if let theDate = maybeDateModified {
|
||||||
|
theResults.append("\(dateStringTag(date: theDate)) Unsigned")
|
||||||
|
} else {
|
||||||
|
theResults.append("Unsigned")
|
||||||
|
}
|
||||||
|
|
||||||
|
return theResults.joined(separator: " - ")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// MARK: - 輸入法的當前的簡繁體中文模式
|
// MARK: - 輸入法的當前的簡繁體中文模式
|
||||||
|
|
Loading…
Reference in New Issue