mirror of
https://github.com/VGEAREN/Stockbar.git
synced 2026-10-06 14:33:11 +08:00
v1.1.5: Add confirmation dialog before auto-update
- Show NSAlert with version info when new version found - User must confirm before download begins Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
66b77aee04
commit
729b03eb6e
@@ -72,7 +72,14 @@ final class UpdateChecker: ObservableObject {
|
||||
return finish("未找到安装包")
|
||||
}
|
||||
|
||||
// 3. 下载 + 安装
|
||||
// 3. 弹窗确认
|
||||
isBusy = false
|
||||
status = ""
|
||||
let confirmed = confirmUpdate(latest: latest, current: current)
|
||||
guard confirmed else { return }
|
||||
|
||||
// 4. 下载 + 安装
|
||||
isBusy = true
|
||||
status = "正在下载 v\(latest)…"
|
||||
await downloadAndInstall(url: downloadURL, version: latest, releaseBody: release.body)
|
||||
}
|
||||
@@ -169,6 +176,17 @@ final class UpdateChecker: ObservableObject {
|
||||
return components[1].trimmingCharacters(in: .whitespaces)
|
||||
}
|
||||
|
||||
// MARK: - 确认弹窗
|
||||
|
||||
private func confirmUpdate(latest: String, current: String) -> Bool {
|
||||
let alert = NSAlert()
|
||||
alert.messageText = "发现新版本 v\(latest)"
|
||||
alert.informativeText = "当前版本 v\(current),是否立即更新?"
|
||||
alert.addButton(withTitle: "立即更新")
|
||||
alert.addButton(withTitle: "暂不更新")
|
||||
return alert.runModal() == .alertFirstButtonReturn
|
||||
}
|
||||
|
||||
// MARK: - 辅助
|
||||
|
||||
private func finish(_ msg: String) {
|
||||
|
||||
Reference in New Issue
Block a user