- 新增 dialog_windows.go、dialog_darwin.go、dialog_linux.go - 使用 Go 构建标签实现条件编译 - 修复跨平台编译错误(syscall.NewLazyDLL 在 macOS/Linux 未定义) - 实现 Linux 多工具降级策略(zenity → kdialog → notify-send → xmessage → stderr) - 实现 macOS AppleScript 字符转义 - 更新 messagebox_test.go 构建标签 - 更新 desktop-app spec 新增 Linux 降级策略和 macOS 字符转义规范
39 lines
802 B
Go
39 lines
802 B
Go
//go:build windows
|
|
|
|
package main
|
|
|
|
import (
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
const (
|
|
MB_ICONERROR = 0x10
|
|
MB_ICONINFORMATION = 0x40
|
|
)
|
|
|
|
var (
|
|
user32 = syscall.NewLazyDLL("user32.dll")
|
|
procMessageBoxW = user32.NewProc("MessageBoxW")
|
|
)
|
|
|
|
func showError(title, message string) {
|
|
messageBox(title, message, MB_ICONERROR)
|
|
}
|
|
|
|
func showAbout() {
|
|
message := "Nex Gateway\n\nAI Gateway - 统一的大模型 API 网关\n\nhttps://github.com/nex/gateway"
|
|
messageBox("关于 Nex Gateway", message, MB_ICONINFORMATION)
|
|
}
|
|
|
|
func messageBox(title, message string, flags uint) {
|
|
titlePtr, _ := syscall.UTF16PtrFromString(title)
|
|
messagePtr, _ := syscall.UTF16PtrFromString(message)
|
|
procMessageBoxW.Call(
|
|
0,
|
|
uintptr(unsafe.Pointer(messagePtr)),
|
|
uintptr(unsafe.Pointer(titlePtr)),
|
|
uintptr(flags),
|
|
)
|
|
}
|