feat(updates): 使用 Sparkle 从发布 ZIP 下载并重启更新
This commit is contained in:
@@ -8,7 +8,6 @@ struct MenuPanelView: View {
|
||||
let updates: ReleaseUpdates
|
||||
var presentation = PanelPresentation()
|
||||
var onOpenSettings: () -> Void = {}
|
||||
var onOpenAbout: () -> Void = {}
|
||||
var onPreferredHeight: (CGFloat) -> Void = { _ in }
|
||||
@Environment(\.locale) var locale
|
||||
@State private var panelSize = PanelLayout.contentSize(visible: NSScreen.main?.visibleFrame ?? CGRect(x: 0, y: 0, width: 1000, height: 760))
|
||||
@@ -137,7 +136,15 @@ struct MenuPanelView: View {
|
||||
.frame(width: 22, height: 22)
|
||||
HStack(alignment: .top, spacing: 3) {
|
||||
Text("Kymo").font(.system(size: 17, weight: .semibold))
|
||||
if let version = Self.version {
|
||||
if updates.version != nil {
|
||||
UpdateAction(phase: updates.phase, version: updates.version, compact: true, action: updates.performAction)
|
||||
.buttonStyle(.plain)
|
||||
.font(.system(size: 10, weight: .semibold))
|
||||
.foregroundStyle(Color.accentColor)
|
||||
.padding(.horizontal, 5).padding(.vertical, 2)
|
||||
.background(Color.accentColor.opacity(0.12), in: Capsule())
|
||||
.offset(y: -2)
|
||||
} else if let version = Self.version {
|
||||
Text(verbatim: "v" + version)
|
||||
.font(.system(size: 9, weight: .semibold)).monospacedDigit()
|
||||
.padding(.horizontal, 5).padding(.vertical, 1)
|
||||
@@ -206,13 +213,6 @@ struct MenuPanelView: View {
|
||||
}
|
||||
.help(metrics.isPaused ? Text("action.resume") : Text("action.pause"))
|
||||
.accessibilityLabel(metrics.isPaused ? Text("action.resume") : Text("action.pause"))
|
||||
if updates.available != nil {
|
||||
Button(action: onOpenAbout) {
|
||||
Image(systemName: "arrow.down.circle.fill").frame(width: 20, height: 20)
|
||||
.foregroundStyle(Color.accentColor)
|
||||
}
|
||||
.help(Text("updates.available")).accessibilityLabel(Text("updates.available"))
|
||||
}
|
||||
Button(action: onOpenSettings) {
|
||||
Image(systemName: "gearshape").frame(width: 20, height: 20)
|
||||
}
|
||||
|
||||
@@ -100,24 +100,22 @@ struct AppearanceSettingsView: View {
|
||||
Section {
|
||||
Toggle("updates.automatic", isOn: $updates.automatic)
|
||||
.toggleStyle(.checkbox)
|
||||
Text("updates.schedule").font(.callout).foregroundStyle(.secondary)
|
||||
HStack {
|
||||
Button("updates.check") { updates.check() }
|
||||
.disabled(updates.phase == .checking)
|
||||
switch updates.phase {
|
||||
case .idle: EmptyView()
|
||||
case .checking: Text("updates.checking").foregroundStyle(.secondary)
|
||||
case .failed: Text("updates.failed").foregroundStyle(.secondary)
|
||||
case .checked:
|
||||
if updates.available == nil { Text("updates.current").foregroundStyle(.secondary) }
|
||||
if let version = updates.version {
|
||||
Text("updates.new \(version.label)")
|
||||
} else if updates.phase == .current {
|
||||
Text("updates.current").foregroundStyle(.secondary)
|
||||
}
|
||||
Spacer()
|
||||
UpdateAction(phase: updates.phase, version: updates.version, action: updates.performAction)
|
||||
}
|
||||
if let release = updates.available {
|
||||
let display = release.build.map { "\(release.tagName) (\($0))" } ?? release.tagName
|
||||
LabeledContent {
|
||||
Link("updates.releasePage", destination: release.page)
|
||||
} label: {
|
||||
Text("updates.new \(display)")
|
||||
}
|
||||
if updates.phase == .downloading || updates.phase == .extracting {
|
||||
ProgressView(value: updates.fraction).progressViewStyle(.linear)
|
||||
}
|
||||
if let error = updates.errorMessage {
|
||||
Text(verbatim: error).font(.callout).foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user