将 macOS 桌面应用改为通用二进制并动态写入最低系统版本,避免 Intel Mac 无法启动。统一桌面应用名称与托盘展示,并补充测试确保相关行为稳定。
34 lines
902 B
Go
34 lines
902 B
Go
//go:build darwin
|
|
|
|
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 showAbout() {
|
|
script := fmt.Sprintf(`display dialog "%s" buttons {"OK"} default button "OK" with title "%s"`,
|
|
escapeAppleScript(aboutMessage()), escapeAppleScript(appAboutTitle))
|
|
if err := exec.Command("osascript", "-e", script).Run(); err != nil {
|
|
dialogLogger().Warn("显示关于对话框失败", zap.Error(err))
|
|
}
|
|
}
|
|
|
|
func escapeAppleScript(s string) string {
|
|
s = strings.ReplaceAll(s, "\\", "\\\\")
|
|
s = strings.ReplaceAll(s, "\"", "\\\"")
|
|
return s
|
|
}
|