新增资产模块,包含云存储与媒体库流程

为云端与素材管理页面接入首页路由,将共享云存储模型迁入 Assets 模块,并补充 API/ViewModel 测试。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-23 16:10:20 +08:00
parent ffb16eca29
commit cac22fcc56
15 changed files with 3431 additions and 75 deletions

View File

@ -283,76 +283,6 @@ struct UploadFileItem: Encodable, Equatable {
}
}
///
struct CloudDriveFile: Decodable, Identifiable, Hashable {
let id: Int
let parentFolderId: Int
let fileUrl: String
let coverUrl: String
let updatedAt: String
let name: String
let createdAt: String
let childNum: Int
let type: Int
let fileSize: Int64
///
var isFolder: Bool { type == 99 }
///
var isVideo: Bool {
type == 1 || Self.hasVideoExtension(name) || Self.hasVideoExtension(fileUrl)
}
///
private static func hasVideoExtension(_ value: String) -> Bool {
["mp4", "mov", "m4v", "avi"].contains(URL(string: value)?.pathExtension.lowercased() ?? URL(fileURLWithPath: value).pathExtension.lowercased())
}
/// 线
enum CodingKeys: String, CodingKey {
case id
case parentFolderId = "parent_folder_id"
case fileUrl = "file_url"
case coverUrl = "cover_url"
case updatedAt = "updated_at"
case name
case createdAt = "created_at"
case childNum = "child_num"
case type
case fileSize = "file_size"
}
///
init(id: Int, name: String) {
self.id = id
parentFolderId = 0
fileUrl = ""
coverUrl = ""
updatedAt = ""
self.name = name
createdAt = ""
childNum = 0
type = 99
fileSize = 0
}
///
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decodeLossyInt(forKey: .id) ?? 0
parentFolderId = try container.decodeLossyInt(forKey: .parentFolderId) ?? 0
fileUrl = try container.decodeLossyString(forKey: .fileUrl)
coverUrl = try container.decodeLossyString(forKey: .coverUrl)
updatedAt = try container.decodeLossyString(forKey: .updatedAt)
name = try container.decodeLossyString(forKey: .name)
createdAt = try container.decodeLossyString(forKey: .createdAt)
childNum = try container.decodeLossyInt(forKey: .childNum) ?? 0
type = try container.decodeLossyInt(forKey: .type) ?? 0
fileSize = Int64(try container.decodeLossyInt(forKey: .fileSize) ?? 0)
}
}
private extension KeyedDecodingContainer {
/// String Bool
func decodeLossyString(forKey key: Key) throws -> String {