refactor: 调整盲盒结构体到Models目录
This commit is contained in:
parent
9e965c1e4e
commit
b07de811a5
@ -67,135 +67,7 @@ struct AVPlayerController: UIViewControllerRepresentable {
|
||||
}
|
||||
}
|
||||
|
||||
struct BlindBoxView: View {
|
||||
enum BlindBoxMediaType {
|
||||
case video
|
||||
case image
|
||||
case all
|
||||
}
|
||||
// 盲盒列表
|
||||
struct BlindList: Codable, Identifiable {
|
||||
// API 返回为字符串,这里按字符串处理
|
||||
let id: String
|
||||
let boxCode: String
|
||||
let userId: String
|
||||
let name: String
|
||||
let boxType: String
|
||||
let features: String?
|
||||
let resultFile: FileInfo?
|
||||
let status: String
|
||||
let workflowInstanceId: String?
|
||||
let videoGenerateTime: String?
|
||||
let createTime: String
|
||||
let coverFile: FileInfo?
|
||||
let description: String?
|
||||
|
||||
struct FileInfo: Codable {
|
||||
let id: String
|
||||
let fileName: String?
|
||||
let url: String?
|
||||
// 为了兼容任意元数据结构,这里使用字典的最宽松版本
|
||||
// 如果后续需要更强类型,可以引入自定义的 AnyCodable/JSONValue
|
||||
let metadata: [String: String]?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case fileName = "file_name"
|
||||
case url
|
||||
case metadata
|
||||
}
|
||||
}
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case boxCode = "box_code"
|
||||
case userId = "user_id"
|
||||
case name
|
||||
case boxType = "box_type"
|
||||
case features
|
||||
case resultFile = "result_file"
|
||||
case status
|
||||
case workflowInstanceId = "workflow_instance_id"
|
||||
case videoGenerateTime = "video_generate_time"
|
||||
case createTime = "create_time"
|
||||
case coverFile = "cover_file"
|
||||
case description
|
||||
}
|
||||
}
|
||||
// 盲盒数量
|
||||
struct BlindCount: Codable {
|
||||
let availableQuantity: Int
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case availableQuantity = "available_quantity"
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - BlindBox Response Model
|
||||
|
||||
struct BlindBoxData: Codable {
|
||||
let id: Int64
|
||||
let boxCode: String
|
||||
let userId: Int64
|
||||
let name: String
|
||||
let boxType: String
|
||||
let features: String?
|
||||
let url: String?
|
||||
let status: String
|
||||
let workflowInstanceId: String?
|
||||
// 视频生成时间
|
||||
let videoGenerateTime: String?
|
||||
let createTime: String
|
||||
let description: String?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case boxCode = "box_code"
|
||||
case userId = "user_id"
|
||||
case name
|
||||
case boxType = "box_type"
|
||||
case features
|
||||
case url
|
||||
case status
|
||||
case workflowInstanceId = "workflow_instance_id"
|
||||
case videoGenerateTime = "video_generate_time"
|
||||
case createTime = "create_time"
|
||||
case description
|
||||
}
|
||||
|
||||
init(id: Int64, boxCode: String, userId: Int64, name: String, boxType: String, features: String?, url: String?, status: String, workflowInstanceId: String?, videoGenerateTime: String?, createTime: String, description: String?) {
|
||||
self.id = id
|
||||
self.boxCode = boxCode
|
||||
self.userId = userId
|
||||
self.name = name
|
||||
self.boxType = boxType
|
||||
self.features = features
|
||||
self.url = url
|
||||
self.status = status
|
||||
self.workflowInstanceId = workflowInstanceId
|
||||
self.videoGenerateTime = videoGenerateTime
|
||||
self.createTime = createTime
|
||||
self.description = description
|
||||
}
|
||||
|
||||
init(from listItem: BlindList) {
|
||||
self.init(
|
||||
id: Int64(listItem.id) ?? 0,
|
||||
boxCode: listItem.boxCode,
|
||||
userId: Int64(listItem.userId) ?? 0,
|
||||
name: listItem.name,
|
||||
boxType: listItem.boxType,
|
||||
features: listItem.features,
|
||||
url: listItem.resultFile?.url,
|
||||
status: listItem.status,
|
||||
workflowInstanceId: listItem.workflowInstanceId,
|
||||
videoGenerateTime: listItem.videoGenerateTime,
|
||||
createTime: listItem.createTime,
|
||||
description: listItem.description
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
struct BlindBoxView: View {
|
||||
let mediaType: BlindBoxMediaType
|
||||
@State private var showModal = false // 控制用户资料弹窗显示
|
||||
@State private var showSettings = false // 控制设置页面显示
|
||||
|
||||
131
wake/Models/BlindModels.swift
Normal file
131
wake/Models/BlindModels.swift
Normal file
@ -0,0 +1,131 @@
|
||||
import Foundation
|
||||
|
||||
// MARK: - Blind Box Media Type
|
||||
enum BlindBoxMediaType {
|
||||
case video
|
||||
case image
|
||||
case all
|
||||
}
|
||||
|
||||
// MARK: - Blind Box List
|
||||
struct BlindList: Codable, Identifiable {
|
||||
// API 返回为字符串,这里按字符串处理
|
||||
let id: String
|
||||
let boxCode: String
|
||||
let userId: String
|
||||
let name: String
|
||||
let boxType: String
|
||||
let features: String?
|
||||
let resultFile: FileInfo?
|
||||
let status: String
|
||||
let workflowInstanceId: String?
|
||||
let videoGenerateTime: String?
|
||||
let createTime: String
|
||||
let coverFile: FileInfo?
|
||||
let description: String?
|
||||
|
||||
struct FileInfo: Codable {
|
||||
let id: String
|
||||
let fileName: String?
|
||||
let url: String?
|
||||
// 为了兼容任意元数据结构,这里使用字典的最宽松版本
|
||||
// 如果后续需要更强类型,可以引入自定义的 AnyCodable/JSONValue
|
||||
let metadata: [String: String]?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case fileName = "file_name"
|
||||
case url
|
||||
case metadata
|
||||
}
|
||||
}
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case boxCode = "box_code"
|
||||
case userId = "user_id"
|
||||
case name
|
||||
case boxType = "box_type"
|
||||
case features
|
||||
case resultFile = "result_file"
|
||||
case status
|
||||
case workflowInstanceId = "workflow_instance_id"
|
||||
case videoGenerateTime = "video_generate_time"
|
||||
case createTime = "create_time"
|
||||
case coverFile = "cover_file"
|
||||
case description
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Blind Box Count
|
||||
struct BlindCount: Codable {
|
||||
let availableQuantity: Int
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case availableQuantity = "available_quantity"
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Blind Box Data
|
||||
struct BlindBoxData: Codable {
|
||||
let id: Int64
|
||||
let boxCode: String
|
||||
let userId: Int64
|
||||
let name: String
|
||||
let boxType: String
|
||||
let features: String?
|
||||
let url: String?
|
||||
let status: String
|
||||
let workflowInstanceId: String?
|
||||
// 视频生成时间
|
||||
let videoGenerateTime: String?
|
||||
let createTime: String
|
||||
let description: String?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case boxCode = "box_code"
|
||||
case userId = "user_id"
|
||||
case name
|
||||
case boxType = "box_type"
|
||||
case features
|
||||
case url
|
||||
case status
|
||||
case workflowInstanceId = "workflow_instance_id"
|
||||
case videoGenerateTime = "video_generate_time"
|
||||
case createTime = "create_time"
|
||||
case description
|
||||
}
|
||||
|
||||
init(id: Int64, boxCode: String, userId: Int64, name: String, boxType: String, features: String?, url: String?, status: String, workflowInstanceId: String?, videoGenerateTime: String?, createTime: String, description: String?) {
|
||||
self.id = id
|
||||
self.boxCode = boxCode
|
||||
self.userId = userId
|
||||
self.name = name
|
||||
self.boxType = boxType
|
||||
self.features = features
|
||||
self.url = url
|
||||
self.status = status
|
||||
self.workflowInstanceId = workflowInstanceId
|
||||
self.videoGenerateTime = videoGenerateTime
|
||||
self.createTime = createTime
|
||||
self.description = description
|
||||
}
|
||||
|
||||
init(from listItem: BlindList) {
|
||||
self.init(
|
||||
id: Int64(listItem.id) ?? 0,
|
||||
boxCode: listItem.boxCode,
|
||||
userId: Int64(listItem.userId) ?? 0,
|
||||
name: listItem.name,
|
||||
boxType: listItem.boxType,
|
||||
features: listItem.features,
|
||||
url: listItem.resultFile?.url,
|
||||
status: listItem.status,
|
||||
workflowInstanceId: listItem.workflowInstanceId,
|
||||
videoGenerateTime: listItem.videoGenerateTime,
|
||||
createTime: listItem.createTime,
|
||||
description: listItem.description
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ enum AppRoute: Hashable {
|
||||
case feedbackView
|
||||
case feedbackDetail(type: FeedbackView.FeedbackType)
|
||||
case mediaUpload
|
||||
case blindBox(mediaType: BlindBoxView.BlindBoxMediaType)
|
||||
case blindBox(mediaType: BlindBoxMediaType)
|
||||
case blindOutcome(media: MediaType, time: String? = nil, description: String? = nil)
|
||||
case memories
|
||||
case subscribe
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user