feat: redesign travel album management
This commit is contained in:
@@ -277,4 +277,22 @@ enum TravelAlbumDisplayFormatter {
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
/// 将服务端创建时间格式化为摘要卡使用的 `yyyy/MM/dd HH:mm`。
|
||||
static func creationTimeText(_ text: String) -> String {
|
||||
guard !text.isEmpty else { return "--" }
|
||||
let normalized = text.replacingOccurrences(of: "T", with: " ")
|
||||
guard normalized.count >= 16 else { return normalized }
|
||||
return String(normalized.prefix(16)).replacingOccurrences(of: "-", with: "/")
|
||||
}
|
||||
|
||||
/// 计算相册摘要卡封面,按相册、素材缩略图、素材原图顺序回退。
|
||||
static func albumCoverURL(album: TravelAlbum?, materials: [TravelAlbumMaterial]) -> String {
|
||||
if let coverURL = album?.coverUrl.trimmingCharacters(in: .whitespacesAndNewlines), !coverURL.isEmpty {
|
||||
return coverURL
|
||||
}
|
||||
guard let first = materials.first else { return "" }
|
||||
let materialCover = first.coverUrl.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
return materialCover.isEmpty ? first.fileUrl.trimmingCharacters(in: .whitespacesAndNewlines) : materialCover
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user