迁移到 mygo 单进程架构并接入签名自更新
- 单进程:托盘常驻 + 原生设置窗口(internal/settings),移除 Wails 前端与 IPC - 触发器(鼠标角落 / 边缘滚轮 / 热键)+ 规则引擎 + 动作注册表 - 调节提示条:截屏 + glass.Blur 三层毛玻璃、背景跟随屏幕变化、悬停光感与拖动 - 音量 Core Audio COM、亮度 DDC/CI(gamma 兜底)、多显示器求平均 - 配置热重载 + 版本迁移 v1→v5、便携模式、崩溃取证三件套 - updater/native 插件 + 托盘「检查更新…」,watchdog 识别更新重启 - 自建 Gitea 发布:scripts/publish-gitea.ps1(updates.url 指向 latest Release)
This commit is contained in:
1 parent
814012ec52
commit
0b8b9b0775
202 files changed
+7254
-13572
No files matched your search
@@ -1,3 +1,4 @@
|
||||
// 系统交互封装:打开路径/URL、带参启动进程、启动期消息框。
|
||||
package windows
|
||||
|
||||
import (
|
||||
@@ -6,49 +7,63 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var (
|
||||
user32 = syscall.NewLazyDLL("user32.dll")
|
||||
shell32 = syscall.NewLazyDLL("shell32.dll")
|
||||
kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
||||
procMessageBoxW = user32.NewProc("MessageBoxW")
|
||||
procShellExecuteW = shell32.NewProc("ShellExecuteW")
|
||||
const (
|
||||
swShowNormal = 1
|
||||
mbIconInformation = 0x00000040
|
||||
)
|
||||
|
||||
// ShowMessageBox 显示模态消息框(单实例冲突等提示用)。
|
||||
func ShowMessageBox(title, text string) {
|
||||
titlePtr, _ := syscall.UTF16PtrFromString(title)
|
||||
textPtr, _ := syscall.UTF16PtrFromString(text)
|
||||
procMessageBoxW.Call(0, uintptr(unsafe.Pointer(textPtr)), uintptr(unsafe.Pointer(titlePtr)), 0x00000040 /* MB_ICONINFORMATION */)
|
||||
}
|
||||
var (
|
||||
procShellExecuteW = syscall.NewLazyDLL("shell32.dll").NewProc("ShellExecuteW")
|
||||
procMessageBoxW = syscall.NewLazyDLL("user32.dll").NewProc("MessageBoxW")
|
||||
)
|
||||
|
||||
// OpenPath 用系统默认程序打开路径(目录或文件),例如 ShellExecute 打开配置目录。
|
||||
// OpenPath 用系统默认关联打开路径或 URL(无参数)。
|
||||
func OpenPath(path string) error {
|
||||
return OpenPathWithArgs(path, "")
|
||||
}
|
||||
|
||||
// OpenPathWithArgs 用系统默认程序打开路径,并附加命令行参数。
|
||||
// 参数为结构化字符串,不经过 cmd /c(架构文档 §9.2 约束)。
|
||||
// OpenPathWithArgs 通过 ShellExecuteW 打开路径并传入命令行参数。
|
||||
// 安全约束:path 与 args 作为独立参数传递,不做 shell 拼接。
|
||||
func OpenPathWithArgs(path, args string) error {
|
||||
p, err := syscall.UTF16PtrFromString(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("shell execute %q: %w", path, err)
|
||||
}
|
||||
var argPtr *uint16
|
||||
if args != "" {
|
||||
a, err := syscall.UTF16PtrFromString(args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("shell execute %q: %w", path, err)
|
||||
}
|
||||
argPtr = a
|
||||
}
|
||||
verb, err := syscall.UTF16PtrFromString("open")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var argsPtr *uint16
|
||||
if args != "" {
|
||||
argsPtr, err = syscall.UTF16PtrFromString(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// ShellExecuteW(hwnd, "open", path, args, NULL, SW_SHOWNORMAL)
|
||||
r, _, _ := procShellExecuteW.Call(0, uintptr(unsafe.Pointer(openVerb())), uintptr(unsafe.Pointer(p)), uintptr(unsafe.Pointer(argsPtr)), 0, 1)
|
||||
r, _, _ := procShellExecuteW.Call(
|
||||
0,
|
||||
uintptr(unsafe.Pointer(verb)),
|
||||
uintptr(unsafe.Pointer(p)),
|
||||
uintptr(unsafe.Pointer(argPtr)),
|
||||
0,
|
||||
swShowNormal,
|
||||
)
|
||||
if r <= 32 {
|
||||
return fmt.Errorf("shell execute %q failed: code %d", path, r)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func openVerb() *uint16 {
|
||||
s, _ := syscall.UTF16PtrFromString("open")
|
||||
return s
|
||||
// ShowMessageBox 显示阻塞式信息框(仅用于启动期致命提示:单实例冲突等)。
|
||||
func ShowMessageBox(title, text string) {
|
||||
t, err := syscall.UTF16PtrFromString(title)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
m, err := syscall.UTF16PtrFromString(text)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
procMessageBoxW.Call(0, uintptr(unsafe.Pointer(m)), uintptr(unsafe.Pointer(t)), mbIconInformation)
|
||||
}
|
||||
Reference in new issue
Block a user