Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions MeoAsstMac/Core/Maa.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,20 @@ import Foundation
import MaaCore
import SwiftyJSON

@_silgen_name("AsstGetVersion")
private func MaaCoreAsstGetVersion() -> UnsafePointer<CChar>?

actor MAAProvider {
static let shared = MAAProvider()

static let coreVersion: String = {
guard let versionPointer = MaaCoreAsstGetVersion() else {
return "Unknown"
}

return String(cString: versionPointer)
}()

private init() {}

func loadResource(path: String) throws {
Expand Down
2 changes: 2 additions & 0 deletions MeoAsstMac/Model/MAAViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,14 @@ extension MAAViewModel {
"""
外部资源版本:\(currentResourceVersion.title)
更新时间:\(currentResourceVersion.last_updated)
\(MaaVersionInfo.coreVersionLogLine())
""")
} else {
logTrace(
"""
内置资源版本:\(currentResourceVersion.title)
更新时间:\(currentResourceVersion.last_updated)
\(MaaVersionInfo.coreVersionLogLine())
""")
let url = documentsDirectory.appendingPathComponent("resource", isDirectory: true)
try? FileManager.default.removeItem(at: url)
Expand Down
14 changes: 14 additions & 0 deletions MeoAsstMac/Settings/UpdaterSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Sparkle
import SwiftUI
import AppKit

struct UpdaterSettingsView: View {
private let updater: SPUUpdater
Expand Down Expand Up @@ -38,6 +39,10 @@ struct UpdaterSettingsView: View {
.onChange(of: automaticallyDownloadsUpdates) { newValue in
updater.automaticallyDownloadsUpdates = newValue
}

Button("复制版本信息") {
copyVersionInfo()
}

Divider()

Expand All @@ -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 {
Expand Down
24 changes: 24 additions & 0 deletions MeoAsstMac/Utils/ResourceUpdater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,27 @@ 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)
"""
}

static func coreVersionLogLine() -> String {
String(localized: "Core Version: \(coreVersion)")
}
}
23 changes: 23 additions & 0 deletions Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,15 @@
},
"PV-烟花筹委会" : {

},
"RA-1" : {

},
"RA-4" : {

},
"RA-15" : {

},
"Read item_index.json failed: %@" : {
"localizations" : {
Expand Down Expand Up @@ -2238,7 +2247,18 @@
}
}
},
"内置资源版本:%@\nMaaCore 版本:%@\n更新时间:%@" : {
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "new",
"value" : "内置资源版本:%1$@\nMaaCore 版本:%2$@\n更新时间:%3$@"
}
}
}
},
"内置资源版本:%@\n更新时间:%@" : {
"extractionState" : "stale",
"localizations" : {
"ko" : {
"stringUnit" : {
Expand Down Expand Up @@ -2759,6 +2779,9 @@
}
}
}
},
"复制版本信息" : {

},
"复制结果JSON至剪贴板:" : {
"localizations" : {
Expand Down