1
0

feat: 增强桌面启动失败提示与测试覆盖

This commit is contained in:
2026-05-08 23:42:48 +08:00
parent c524e8f928
commit 2dec9e5c54
21 changed files with 1857 additions and 297 deletions

View File

@@ -4,17 +4,35 @@ package main
import (
"fmt"
"os/exec"
"strings"
"go.uber.org/zap"
)
func showError(title, message string) {
script := fmt.Sprintf(`display dialog "%s" buttons {"OK"} default button "OK" with title "%s"`,
escapeAppleScript(message), escapeAppleScript(title))
if err := exec.Command("osascript", "-e", script).Run(); err != nil {
dialogLogger().Warn("显示错误对话框失败", zap.Error(err))
func platformStartupChannels(runner commandRunner) []promptChannel {
return []promptChannel{
{
name: "macos-notification",
available: func() error {
_, err := runner.LookPath("osascript")
return err
},
run: func(req promptRequest) error {
script := fmt.Sprintf(`display notification "%s" with title "%s" subtitle "%s"`,
escapeAppleScript(req.message), escapeAppleScript(req.title), escapeAppleScript(req.subtitle))
return runner.Run(promptCommandTimeout, nil, "osascript", "-e", script)
},
},
{
name: "macos-alert",
available: func() error {
_, err := runner.LookPath("osascript")
return err
},
run: func(req promptRequest) error {
script := fmt.Sprintf(`display alert "%s" message "%s" as critical buttons {"OK"} default button "OK"`,
escapeAppleScript(req.title), escapeAppleScript(req.message))
return runner.Run(promptCommandTimeout, nil, "osascript", "-e", script)
},
},
}
}