punchnet-macos/punchnet/Views/Update/AppUpdateView.swift
2026-03-23 14:58:32 +08:00

78 lines
2.5 KiB
Swift

//
// AppUpdateView.swift
// punchnet
//
// Created by on 2026/3/23.
//
import SwiftUI
struct AppUpdateView: View {
let info: SDLAPIClient.AppUpgradeInfo
var dismissAction: () -> Void
var body: some View {
VStack(spacing: 0) {
// Header
VStack(spacing: 12) {
Image(systemName: "arrow.up.rocket.fill")
.font(.system(size: 40))
.foregroundStyle(.blue.gradient)
Text("新版本已就绪")
.font(.title3.bold())
Text("版本号: \(info.latestVersion)")
.font(.caption)
.foregroundColor(.secondary)
}
.padding(.top, 30)
.padding(.bottom, 20)
.frame(maxWidth: .infinity)
.background(Color.blue.opacity(0.05))
//
VStack(alignment: .leading, spacing: 12) {
Text("更新说明")
.font(.subheadline.bold())
ScrollView {
Text(info.releaseNotes)
.font(.subheadline)
.foregroundColor(.secondary)
.lineSpacing(4)
.frame(maxWidth: .infinity, alignment: .leading)
}
.frame(maxHeight: 120)
//
HStack(spacing: 12) {
if !info.forceUpdate {
Button("稍后") {
dismissAction()
}
.buttonStyle(.plain)
.frame(width: 80)
}
Button {
if let forceUpdateUrl = info.forceUpdateUrl, let url = URL(string: forceUpdateUrl) {
NSWorkspace.shared.open(url)
}
} label: {
Text(info.forceUpdate ? "立即更新" : "下载并安装")
.fontWeight(.bold)
.frame(maxWidth: .infinity)
}
.buttonStyle(.borderedProminent)
.controlSize(.large)
}
.padding(.top, 10)
}
.padding(25)
}
.frame(width: 360)
.background(VisualEffectView(material: .underWindowBackground, blendingMode: .behindWindow))
}
}