From cba27d10c2f960a2c85f4c96d2ce310acf1c95e3 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 3 Jul 2023 22:24:45 +0800 Subject: [PATCH] IMEApp // Add .appVersionLabel(). --- .../Modules/WindowControllers/CtlAboutWindow.swift | 10 +--------- Source/Modules/main.swift | 13 +++++++++++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Source/Modules/WindowControllers/CtlAboutWindow.swift b/Source/Modules/WindowControllers/CtlAboutWindow.swift index 87f43a34..c10e7bae 100644 --- a/Source/Modules/WindowControllers/CtlAboutWindow.swift +++ b/Source/Modules/WindowControllers/CtlAboutWindow.swift @@ -29,17 +29,9 @@ class CtlAboutWindow: NSWindowController { override func windowDidLoad() { super.windowDidLoad() window?.setPosition(vertical: .top, horizontal: .left, padding: 20) - window?.standardWindowButton(.closeButton)?.isHidden = true window?.standardWindowButton(.miniaturizeButton)?.isHidden = true window?.standardWindowButton(.zoomButton)?.isHidden = true - guard - let installingVersion = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] - as? String, - let versionString = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String - else { - return - } if let copyrightLabel = Bundle.main.localizedInfoDictionary?["NSHumanReadableCopyright"] as? String { @@ -50,7 +42,7 @@ class CtlAboutWindow: NSWindowController { { appEULAContent.string = eulaContent + "\n" + eulaContentUpstream } - appVersionLabel.stringValue = "\(versionString) Build \(installingVersion)" + appVersionLabel.stringValue = IMEApp.appVersionLabel } @IBAction func btnBugReport(_: NSButton) { diff --git a/Source/Modules/main.swift b/Source/Modules/main.swift index 4f674cf6..79cc2c97 100644 --- a/Source/Modules/main.swift +++ b/Source/Modules/main.swift @@ -74,6 +74,19 @@ _ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv) // MARK: - Top-level Enums relating to Input Mode and Language Supports. public enum IMEApp { + // MARK: - 獲取輸入法的版本以及建置編號 + + public static var appVersionLabel: String { + guard + let intBuild = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as? String, + let strVer = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String + else { + return "114.514.1919810" + } + + return "\(strVer) Build \(intBuild)" + } + // MARK: - 輸入法的當前的簡繁體中文模式 public static var currentInputMode: Shared.InputMode {