CodexBar 是一个 macOS 菜单栏应用,用于查看本机 Codex 账号状态、额度、Token 用量、详细统计信息
Swift appkitcodexcodex-clideveloper-toolsmacosmacos-appmenu-bar-appopenai-codexproductivityswiftswiftuiusage-tracker
fix: 统一更新提示的版本与构建号展示
Bobfc035c2f8cb2
diff --git a/CodexBar/App/CodexBarApp.swift b/CodexBar/App/CodexBarApp.swiftindex d064d6b..53fd307 100644--- a/CodexBar/App/CodexBarApp.swift+++ b/CodexBar/App/CodexBarApp.swift@@ -32,9 +32,16 @@ nonisolated extension Bundle {/// 版本文案包含构建号; 版本缺失时回退 `--`var displayVersionLabel: String {- guard let version = shortVersionString else { return "--" }+ Self.displayVersionLabel(+ version: shortVersionString,+ build: object(forInfoDictionaryKey: "CFBundleVersion") as? String+ )+ }++ static func displayVersionLabel(version: String?, build: String?) -> String {+ guard let version else { return "--" }let label = "v\(version)"- guard let build = object(forInfoDictionaryKey: "CFBundleVersion") as? String, !build.isEmpty else { return label }+ guard let build, !build.isEmpty else { return label }return "\(label) (Build \(build))"}}diff --git a/CodexBar/Resources/Localizable.xcstrings b/CodexBar/Resources/Localizable.xcstringsindex 4bb2a0f..0b3d273 100644--- a/CodexBar/Resources/Localizable.xcstrings+++ b/CodexBar/Resources/Localizable.xcstrings@@ -7111,13 +7111,13 @@"en" : {"stringUnit" : {"state" : "translated",- "value" : "Click to install v%@"+ "value" : "Click to install %@"}},"zh-Hans" : {"stringUnit" : {"state" : "translated",- "value" : "点击安装 v%@"+ "value" : "点击安装 %@"}}}@@ -7143,13 +7143,13 @@"en" : {"stringUnit" : {"state" : "translated",- "value" : "New version: v%@"+ "value" : "New version: %@"}},"zh-Hans" : {"stringUnit" : {"state" : "translated",- "value" : "发现新版本: v%@"+ "value" : "发现新版本: %@"}}}diff --git a/CodexBar/Services/Updates/AppUpdater.swift b/CodexBar/Services/Updates/AppUpdater.swiftindex 2cc30bb..7668787 100644--- a/CodexBar/Services/Updates/AppUpdater.swift+++ b/CodexBar/Services/Updates/AppUpdater.swift@@ -7,7 +7,7 @@ import Sparkle@MainActorfinal class AppUpdater: NSObject, ObservableObject {@Published private var settingsCheckMessage: String?- @Published private var pendingInstallation: (version: String, install: () -> Void)?+ @Published private var pendingInstallation: (versionLabel: String, install: () -> Void)?@Published private(set) var availableUpdateMessage: String?@Published private(set) var automaticallyChecksForUpdates = false@@ -15,7 +15,7 @@ final class AppUpdater: NSObject, ObservableObject {if let pendingInstallation {return String(localized: "updater.status.ready-to-install.settings",- defaultValue: "\(pendingInstallation.version)"+ defaultValue: "\(pendingInstallation.versionLabel)")}return settingsCheckMessage@@ -175,7 +175,10 @@ extension AppUpdater: SPUUpdaterDelegate {immediateInstallationBlock immediateInstallHandler: @escaping () -> Void) -> Bool {// 保留当前安装会话, 避免重新检查时恢复已下载更新的信息- pendingInstallation = (item.displayVersionString, immediateInstallHandler)+ pendingInstallation = (+ Bundle.displayVersionLabel(version: item.displayVersionString, build: item.versionString),+ immediateInstallHandler+ )return true}@@ -204,9 +207,10 @@ extension AppUpdater: SPUUpdaterDelegate {func updater(_: SPUUpdater, didFindValidUpdate item: SUAppcastItem) {let version = item.displayVersionString+ let versionLabel = Bundle.displayVersionLabel(version: version, build: item.versionString)let message = String(localized: "updater.status.update-available",- defaultValue: "\(version)"+ defaultValue: "\(versionLabel)")availableUpdateMessage = messagelet trigger = checkTrigger.rawValuediff --git a/Config/BuildNumber.xcconfig b/Config/BuildNumber.xcconfigindex b60e852..1185635 100644--- a/Config/BuildNumber.xcconfig+++ b/Config/BuildNumber.xcconfig@@ -1,3 +1,3 @@// 请勿手动修改// Do not modify manually-CURRENT_PROJECT_VERSION = 313\ No newline at end of file+CURRENT_PROJECT_VERSION = 314\ No newline at end of file