完善素材管理 UI 交互并修复列表解析与时间选择。
MaterialItem 兼容 Android 缺失字段默认值,优化素材详情/列表/标签布局与上下架开关交互,修复个人空间时间选择器初始值。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -121,6 +121,22 @@ struct MaterialItem: Decodable, Sendable, Equatable, Hashable, Identifiable {
|
||||
self.projectName = projectName
|
||||
self.listingStatus = listingStatus
|
||||
}
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
id = try container.decodeIfPresent(Int.self, forKey: .id) ?? 0
|
||||
name = try container.decodeIfPresent(String.self, forKey: .name) ?? ""
|
||||
coverUrl = try container.decodeIfPresent(String.self, forKey: .coverUrl) ?? ""
|
||||
createdAt = try container.decodeIfPresent(String.self, forKey: .createdAt) ?? ""
|
||||
status = try container.decodeIfPresent(Int.self, forKey: .status) ?? 0
|
||||
downloadCount = try container.decodeIfPresent(Int.self, forKey: .downloadCount) ?? 0
|
||||
likesCount = try container.decodeIfPresent(Int.self, forKey: .likesCount) ?? 0
|
||||
collectCount = try container.decodeIfPresent(Int.self, forKey: .collectCount) ?? 0
|
||||
shareCount = try container.decodeIfPresent(Int.self, forKey: .shareCount) ?? 0
|
||||
scenicSpotName = try container.decodeIfPresent(String.self, forKey: .scenicSpotName) ?? ""
|
||||
projectName = try container.decodeIfPresent(String.self, forKey: .projectName) ?? ""
|
||||
listingStatus = try container.decodeIfPresent(Int.self, forKey: .listingStatus) ?? 0
|
||||
}
|
||||
}
|
||||
|
||||
/// 素材列表响应,对齐 Android `MaterialListResponse`。
|
||||
|
||||
Reference in New Issue
Block a user