Skip to content

Commit 1f59e78

Browse files
committed
feat: 修改mac自动更新的方式
1 parent 1b47e14 commit 1f59e78

2 files changed

Lines changed: 13 additions & 19 deletions

File tree

tray/systray.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,18 @@ func (m *Manager) onReady() {
222222
// dialog.Message("Failed to open control panel: %v", err).Title("Error").Error()
223223
// }
224224
case <-m.mRestartUpdate.ClickedCh:
225-
if confirmed := dialog.Message("This will stop all servers and install the update. Continue?").Title("Confirm Update").YesNo(); confirmed {
225+
var msg, title string
226+
if runtime.GOOS == "windows" {
227+
msg = "This will stop all servers and install the update. Continue?"
228+
title = "Confirm Update"
229+
} else if runtime.GOOS == "darwin" {
230+
msg = "the new installer folder will be opened. Please double-click the installer to complete the upgrade. Continue?"
231+
title = "Confirm Update"
232+
} else {
233+
msg = "This will stop all servers and install the update. Continue?"
234+
title = "Confirm Update"
235+
}
236+
if confirmed := dialog.Message(msg).Title(title).YesNo(); confirmed {
226237
if err := m.performUpdate(); err != nil {
227238
dialog.Message("Failed to perform update: %v", err).Title("Error").Error()
228239
}

tray/updater.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -399,25 +399,8 @@ func (p *PKGInstaller) Install() error {
399399
}
400400

401401
func (p *PKGInstaller) installWithAppleScript() error {
402-
slog.Info("installing with AppleScript for elevated privileges")
403-
404-
// 弹出提示框,询问用户是否打开安装包目录
405-
alertScript := fmt.Sprintf(`
406-
display dialog "需要手动安装新版本。是否打开安装包所在目录?" buttons {"取消", "打开目录"} default button "打开目录"
407-
`, p.pkgPath)
408-
409-
cmd := exec.Command("osascript", "-e", alertScript)
410-
output, err := cmd.CombinedOutput()
411-
if err != nil {
412-
slog.Error("AppleScript alert failed:", err)
413-
return fmt.Errorf("AppleScript alert failed: %v", err)
414-
}
415-
416-
if !strings.Contains(string(output), "打开目录") {
417-
return fmt.Errorf("用户取消了安装")
418-
}
402+
slog.Info("直接打开安装包所在目录,等待用户手动安装")
419403

420-
// 打开安装包所在目录
421404
dir := filepath.Dir(p.pkgPath)
422405
openCmd := exec.Command("open", dir)
423406
if err := openCmd.Run(); err != nil {

0 commit comments

Comments
 (0)