From 7adf9800f1ab42b337c4c22867e799ad66bba147 Mon Sep 17 00:00:00 2001 From: ColdSpell Date: Mon, 25 May 2026 15:31:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(macOS):=20=E6=B7=BB=E5=8A=A0=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=B9=B6=E6=98=BE=E7=A4=BA=20Core=20=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MeoAsstMac/Core/Maa.swift | 9 ++++++++ MeoAsstMac/Model/MAAViewModel.swift | 1 + MeoAsstMac/Settings/UpdaterSettingsView.swift | 14 +++++++++++ MeoAsstMac/Utils/ResourceUpdater.swift | 20 ++++++++++++++++ Resources/Localizable.xcstrings | 23 +++++++++++++++++++ 5 files changed, 67 insertions(+) diff --git a/MeoAsstMac/Core/Maa.swift b/MeoAsstMac/Core/Maa.swift index 94f0780c5..b8cb6c0e5 100644 --- a/MeoAsstMac/Core/Maa.swift +++ b/MeoAsstMac/Core/Maa.swift @@ -10,8 +10,17 @@ import Foundation import MaaCore import SwiftyJSON +@_silgen_name("AsstGetVersion") +private func MaaCoreAsstGetVersion() -> UnsafePointer + actor MAAProvider { static let shared = MAAProvider() + + static var coreVersion: String { + String(cString: MaaCoreAsstGetVersion()) + } + + private init() {} func loadResource(path: String) throws { diff --git a/MeoAsstMac/Model/MAAViewModel.swift b/MeoAsstMac/Model/MAAViewModel.swift index a47c21cfa..5c4ddb5dc 100644 --- a/MeoAsstMac/Model/MAAViewModel.swift +++ b/MeoAsstMac/Model/MAAViewModel.swift @@ -347,6 +347,7 @@ extension MAAViewModel { logTrace( """ 内置资源版本:\(currentResourceVersion.title) + MaaCore 版本:\(MAAProvider.coreVersion) 更新时间:\(currentResourceVersion.last_updated) """) let url = documentsDirectory.appendingPathComponent("resource", isDirectory: true) diff --git a/MeoAsstMac/Settings/UpdaterSettingsView.swift b/MeoAsstMac/Settings/UpdaterSettingsView.swift index b34e8bd34..4879b9a58 100644 --- a/MeoAsstMac/Settings/UpdaterSettingsView.swift +++ b/MeoAsstMac/Settings/UpdaterSettingsView.swift @@ -7,6 +7,7 @@ import Sparkle import SwiftUI +import AppKit struct UpdaterSettingsView: View { private let updater: SPUUpdater @@ -38,6 +39,10 @@ struct UpdaterSettingsView: View { .onChange(of: automaticallyDownloadsUpdates) { newValue in updater.automaticallyDownloadsUpdates = newValue } + + Button("复制版本信息") { + copyVersionInfo() + } Divider() @@ -62,6 +67,15 @@ struct UpdaterSettingsView: View { .animation(.default, value: resourceChannel) .padding() } + +//复制更详细的版本信息 + private func copyVersionInfo() { + guard let (_, resourceVersion) = try? resourceChannel.version() else { return } + + let pasteboard = NSPasteboard.general + pasteboard.clearContents() + pasteboard.setString(MaaVersionInfo.text(resourceVersion: resourceVersion), forType: .string) + } } private let mirrorChyanCDK = Binding { diff --git a/MeoAsstMac/Utils/ResourceUpdater.swift b/MeoAsstMac/Utils/ResourceUpdater.swift index 2504fa825..a6161f9d8 100644 --- a/MeoAsstMac/Utils/ResourceUpdater.swift +++ b/MeoAsstMac/Utils/ResourceUpdater.swift @@ -107,3 +107,23 @@ extension MAAResourceChannel { return try decoder.decode(MAAResourceVersion.self, from: data) } } + +enum MaaVersionInfo { + static var uiVersion: String { + let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown" + return version.hasPrefix("v") ? version : "v\(version)" + } + + static var coreVersion: String { + MAAProvider.coreVersion + } + + static func text(resourceVersion: MAAResourceVersion) -> String { + """ + UI Version: \(uiVersion) + Core Version: \(coreVersion) + Resource Version: \(resourceVersion.title) + Resource Time: \(resourceVersion.last_updated) + """ + } +} diff --git a/Resources/Localizable.xcstrings b/Resources/Localizable.xcstrings index aee47be4d..2938573c0 100644 --- a/Resources/Localizable.xcstrings +++ b/Resources/Localizable.xcstrings @@ -1225,6 +1225,15 @@ }, "PV-烟花筹委会" : { + }, + "RA-1" : { + + }, + "RA-4" : { + + }, + "RA-15" : { + }, "Read item_index.json failed: %@" : { "localizations" : { @@ -2238,7 +2247,18 @@ } } }, + "内置资源版本:%@\nMaaCore 版本:%@\n更新时间:%@" : { + "localizations" : { + "zh-Hans" : { + "stringUnit" : { + "state" : "new", + "value" : "内置资源版本:%1$@\nMaaCore 版本:%2$@\n更新时间:%3$@" + } + } + } + }, "内置资源版本:%@\n更新时间:%@" : { + "extractionState" : "stale", "localizations" : { "ko" : { "stringUnit" : { @@ -2759,6 +2779,9 @@ } } } + }, + "复制版本信息" : { + }, "复制结果JSON至剪贴板:" : { "localizations" : { From 029b17ce18454731deeeac51467749099f645110 Mon Sep 17 00:00:00 2001 From: ColdSpell Date: Mon, 25 May 2026 15:53:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?refactor(macOS):=20=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E5=B9=B6=E7=BC=93=E5=AD=98=20Core=20=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MeoAsstMac/Core/Maa.swift | 11 +++++++---- MeoAsstMac/Model/MAAViewModel.swift | 3 ++- MeoAsstMac/Utils/ResourceUpdater.swift | 4 ++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/MeoAsstMac/Core/Maa.swift b/MeoAsstMac/Core/Maa.swift index b8cb6c0e5..10357e743 100644 --- a/MeoAsstMac/Core/Maa.swift +++ b/MeoAsstMac/Core/Maa.swift @@ -11,15 +11,18 @@ import MaaCore import SwiftyJSON @_silgen_name("AsstGetVersion") -private func MaaCoreAsstGetVersion() -> UnsafePointer +private func MaaCoreAsstGetVersion() -> UnsafePointer? actor MAAProvider { static let shared = MAAProvider() - static var coreVersion: String { - String(cString: MaaCoreAsstGetVersion()) - } + static let coreVersion: String = { + guard let versionPointer = MaaCoreAsstGetVersion() else { + return "Unknown" + } + return String(cString: versionPointer) + }() private init() {} diff --git a/MeoAsstMac/Model/MAAViewModel.swift b/MeoAsstMac/Model/MAAViewModel.swift index 5c4ddb5dc..cfc51f8b5 100644 --- a/MeoAsstMac/Model/MAAViewModel.swift +++ b/MeoAsstMac/Model/MAAViewModel.swift @@ -342,13 +342,14 @@ extension MAAViewModel { """ 外部资源版本:\(currentResourceVersion.title) 更新时间:\(currentResourceVersion.last_updated) + \(MaaVersionInfo.coreVersionLogLine()) """) } else { logTrace( """ 内置资源版本:\(currentResourceVersion.title) - MaaCore 版本:\(MAAProvider.coreVersion) 更新时间:\(currentResourceVersion.last_updated) + \(MaaVersionInfo.coreVersionLogLine()) """) let url = documentsDirectory.appendingPathComponent("resource", isDirectory: true) try? FileManager.default.removeItem(at: url) diff --git a/MeoAsstMac/Utils/ResourceUpdater.swift b/MeoAsstMac/Utils/ResourceUpdater.swift index a6161f9d8..881d87569 100644 --- a/MeoAsstMac/Utils/ResourceUpdater.swift +++ b/MeoAsstMac/Utils/ResourceUpdater.swift @@ -126,4 +126,8 @@ enum MaaVersionInfo { Resource Time: \(resourceVersion.last_updated) """ } + + static func coreVersionLogLine() -> String { + String(localized: "Core Version: \(coreVersion)") + } }