From 145b918dbcf11b5438abce313feeb9d27c1e2a72 Mon Sep 17 00:00:00 2001 From: William Date: Tue, 30 Jun 2026 13:58:37 +0600 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=BC=B9=E7=AA=97=E6=9C=AA=E5=9B=9E=E5=A1=AB?= =?UTF-8?q?=E5=8E=9F=E5=86=85=E5=AE=B9=EF=BC=8C=E6=94=B9=E7=94=A8=20sheet(?= =?UTF-8?q?item:)=20=E7=A1=AE=E4=BF=9D=E5=8F=82=E6=95=B0=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E4=BC=A0=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/VODManager/Models/Models.swift | 18 +++++++++++++++++- .../VODManager/Views/AccountListView.swift | 13 +++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) 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) } } }