diff --git a/apps/macos/VODManager/Sources/VODManager/Models/Models.swift b/apps/macos/VODManager/Sources/VODManager/Models/Models.swift index 07c08fe..cdfe6a7 100644 --- a/apps/macos/VODManager/Sources/VODManager/Models/Models.swift +++ b/apps/macos/VODManager/Sources/VODManager/Models/Models.swift @@ -2,7 +2,7 @@ import Foundation import SwiftData @Model -class Account { +class Account: Identifiable { @Attribute(.unique) var id: UUID var name: String var accessKeyId: String @@ -109,6 +109,22 @@ enum DownloadStatus: String, Codable { case pending, downloading, completed, failed } +enum FileConflictStrategy: String, CaseIterable, Identifiable { + case skip + case overwrite + case rename + + var id: String { rawValue } + + var label: String { + switch self { + case .skip: return "跳过已存在文件" + case .overwrite: return "覆盖已有文件" + case .rename: return "自动重命名(加序号)" + } + } +} + struct VideoItem: Identifiable, Codable, Equatable { var id: String { videoId } var videoId: String diff --git a/apps/macos/VODManager/Sources/VODManager/Views/AccountListView.swift b/apps/macos/VODManager/Sources/VODManager/Views/AccountListView.swift index 08d8aae..7a92e59 100644 --- a/apps/macos/VODManager/Sources/VODManager/Views/AccountListView.swift +++ b/apps/macos/VODManager/Sources/VODManager/Views/AccountListView.swift @@ -4,8 +4,8 @@ import SwiftData struct AccountListView: View { @EnvironmentObject var accountStore: AccountStore @Query(sort: \Account.createdAt, order: .reverse) private var accounts: [Account] - @State private var showForm = false @State private var editingAccount: Account? + @State private var showAddForm = false @State private var errorMessage: String? var body: some View { @@ -13,8 +13,7 @@ struct AccountListView: View { HStack { Spacer() Button("添加账号") { - editingAccount = nil - showForm = true + showAddForm = true } .buttonStyle(.borderedProminent) } @@ -62,7 +61,6 @@ struct AccountListView: View { Button("编辑") { editingAccount = account - showForm = true } .buttonStyle(.borderless) @@ -75,8 +73,11 @@ struct AccountListView: View { .padding(.vertical, 4) } } - .sheet(isPresented: $showForm) { - AccountFormView(account: editingAccount) + .sheet(item: $editingAccount) { account in + AccountFormView(account: account) + } + .sheet(isPresented: $showAddForm) { + AccountFormView(account: nil) } } }