Refactor QR scan and share and add QRS support

This commit is contained in:
世界
2026-01-02 16:27:26 +08:00
parent 313cb5d213
commit 52db9bbb39
23 changed files with 1115 additions and 1411 deletions
+10 -2
View File
@@ -16,13 +16,21 @@ public extension Profile {
content.autoUpdate = autoUpdate
content.autoUpdateInterval = autoUpdateInterval
if let lastUpdated {
content.lastUpdated = Int64(lastUpdated.timeIntervalSince1970)
content.lastUpdated = Int64(lastUpdated.timeIntervalSince1970 * 1000)
}
}
return content
}
}
public func dateFromTimestamp(_ timestamp: Int64) -> Date {
if timestamp > 100_000_000_000 {
return Date(timeIntervalSince1970: Double(timestamp) / 1000)
} else {
return Date(timeIntervalSince1970: Double(timestamp))
}
}
@available(iOS 16.0, macOS 13.0, *)
extension Profile: Transferable {
public static var transferRepresentation: some TransferRepresentation {
@@ -51,7 +59,7 @@ public extension LibboxProfileContent {
try config.write(to: profileConfig, atomically: true, encoding: .utf8)
var lastUpdatedAt: Date?
if lastUpdated > 0 {
lastUpdatedAt = Date(timeIntervalSince1970: Double(lastUpdated))
lastUpdatedAt = dateFromTimestamp(lastUpdated)
}
let uniqueProfileName = try await ProfileManager.uniqueName(name)
let profile = Profile(name: uniqueProfileName, type: ProfileType(rawValue: Int(type))!, path: profileConfig.relativePath, remoteURL: remotePath, autoUpdate: autoUpdate, autoUpdateInterval: autoUpdateInterval, lastUpdated: lastUpdatedAt)