IMEApp // Contantiate .appVersionLabel() with build date.

This commit is contained in:
ShikiSuen 2023-07-03 22:34:58 +08:00
parent 20bddbc0cb
commit 34a6f036b5
1 changed files with 20 additions and 5 deletions

View File

@ -76,17 +76,32 @@ _ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv)
public enum IMEApp { public enum IMEApp {
// MARK: - // MARK: -
public static var appVersionLabel: String { public static let appVersionLabel: String = {
guard let maybeStrDate: String? = {
let intBuild = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as? String, guard let executableURL = Bundle.main.executableURL,
let strVer = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String let infoDate = (try? executableURL.resourceValues(forKeys: [.creationDateKey]))?.creationDate
else { else {
return "114.514.1919810" return nil
} }
return "\(strVer) Build \(intBuild)" let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyyMMdd.HHmm"
dateFormatter.timeZone = .init(secondsFromGMT: +28800) ?? .current
let strDate = dateFormatter.string(from: infoDate)
return strDate
}()
guard
let intBuild = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as? String,
let strVer = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String,
let strDate = maybeStrDate
else {
return "1.14.514 - 19190810"
} }
return "\(strVer) Build \(intBuild) - \(strDate)"
}()
// MARK: - // MARK: -
public static var currentInputMode: Shared.InputMode { public static var currentInputMode: Shared.InputMode {