feat: Add a second confirmation when canceling a task

This commit is contained in:
X1a0He
2025-03-27 21:50:38 +08:00
parent a03590bc71
commit cfdd0ed696
6 changed files with 71 additions and 55 deletions

View File

@@ -59,7 +59,7 @@ struct DownloadManagerView: View {
)
}
.background(Color(.clear))
.frame(width:800, height: 600)
.frame(width:750, height: 500)
}
}

View File

@@ -22,6 +22,7 @@ struct DownloadProgressView: View {
@State private var showCommandLineInstall = false
@State private var showCopiedAlert = false
@State private var showDeleteConfirmation = false
@State private var showCancelConfirmation = false
private var statusLabel: some View {
Text(task.status.description)
@@ -82,7 +83,7 @@ struct DownloadProgressView: View {
}
.buttonStyle(BeautifulButtonStyle(baseColor: .orange))
Button(action: onCancel) {
Button(action: { showCancelConfirmation = true }) {
Label("取消", systemImage: "xmark")
.font(.system(size: 13, weight: .medium))
.foregroundColor(.white)
@@ -97,7 +98,7 @@ struct DownloadProgressView: View {
}
.buttonStyle(BeautifulButtonStyle(baseColor: .blue))
Button(action: onCancel) {
Button(action: { showCancelConfirmation = true }) {
Label("取消", systemImage: "xmark")
.font(.system(size: 13, weight: .medium))
.foregroundColor(.white)
@@ -191,7 +192,7 @@ struct DownloadProgressView: View {
}
case .retrying:
Button(action: onCancel) {
Button(action: { showCancelConfirmation = true }) {
Label("取消", systemImage: "xmark")
.font(.system(size: 13, weight: .medium))
.foregroundColor(.white)
@@ -199,14 +200,22 @@ struct DownloadProgressView: View {
.buttonStyle(BeautifulButtonStyle(baseColor: .red))
}
}
.alert("确认删除", isPresented: $showDeleteConfirmation) {
.alert("确认你的操作", isPresented: $showDeleteConfirmation) {
Button("取消", role: .cancel) { }
Button("删除", role: .destructive) {
Button("确认", role: .destructive) {
onRemove()
}
} message: {
Text("确定要删除任务\(task.displayName)吗?")
}
.alert("请确认你的操作", isPresented: $showCancelConfirmation) {
Button("返回", role: .cancel) { }
Button("确认取消", role: .destructive) {
onCancel()
}
} message: {
Text("确定要取消\(task.displayName)的下载吗?")
}
.sheet(isPresented: $showInstallPrompt) {
if task.displayInstallButton {
VStack(spacing: 20) {
@@ -673,6 +682,15 @@ private struct PackageListView: View {
.buttonStyle(BeautifulButtonStyle(baseColor: .blue))
#endif
#if DEBUG
if case .completed = task.status, task.productId != "APRO" {
CommandLineInstallButton(
task: task,
showCommandLineInstall: $showCommandLineInstall,
showCopiedAlert: $showCopiedAlert
)
}
#else
if !ModifySetup.isSetupModified(), case .completed = task.status {
HStack {
Image(systemName: "exclamationmark.triangle.fill")
@@ -696,17 +714,7 @@ private struct PackageListView: View {
}
.padding(.top, 5)
}
if case .completed = task.status, task.productId != "APRO" {
if ModifySetup.isSetupModified() {
CommandLineInstallButton(
task: task,
showCommandLineInstall: $showCommandLineInstall,
showCopiedAlert: $showCopiedAlert
)
}
}
#endif
actionButtons
}

View File

@@ -89,7 +89,7 @@ struct ProductGridView: View {
HStack(spacing: 8) {
Capsule()
.fill(Color.secondary.opacity(0.2))
.fill(Color.green)
.frame(width: 6, height: 6)
Text("获取到 \(products.count) 款产品")
.font(.system(size: 12))

View File

@@ -135,7 +135,7 @@ private struct VersionListView: View {
HStack(spacing: 8) {
Capsule()
.fill(Color.secondary.opacity(0.2))
.fill(Color.green)
.frame(width: 6, height: 6)
Text("获取到 \(filteredVersions.count) 个版本")
.font(.system(size: 12))
@@ -144,7 +144,7 @@ private struct VersionListView: View {
.padding(.bottom, 16)
}
}
.background(Color(NSColor.windowBackgroundColor))
.background(Color(.clear))
}
private var filteredVersions: [(key: String, value: Product.Platform)] {
@@ -455,10 +455,7 @@ private struct DependenciesList: View {
.fill(Color.blue.opacity(0.1))
)
.foregroundColor(.blue.opacity(0.8))
}
.padding(.vertical, 2)
HStack(spacing: 10) {
if dependency.baseVersion != dependency.productVersion {
HStack(spacing: 3) {
Text("base:")
@@ -468,12 +465,17 @@ private struct DependenciesList: View {
.font(.system(size: 10, weight: .medium))
.foregroundColor(.secondary.opacity(0.9))
}
.padding(.horizontal, 4)
.padding(.horizontal, 5)
.padding(.vertical, 1)
.background(Color.secondary.opacity(0.07))
.cornerRadius(2)
.background(
RoundedRectangle(cornerRadius: 3)
.fill(Color.secondary.opacity(0.1))
)
}
}
.padding(.vertical, 2)
HStack(spacing: 10) {
if !dependency.buildGuid.isEmpty {
HStack(spacing: 3) {
Text("buildGuid:")