fix: 修复账号编辑弹窗未回填原内容,改用 sheet(item:) 确保参数正确传入
CI / lint-and-build (push) Has been cancelled

This commit is contained in:
2026-06-30 13:58:37 +06:00
parent 5a13a8e6a6
commit 145b918dbc
2 changed files with 24 additions and 7 deletions
@@ -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
@@ -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)
}
}
}