- 单进程:托盘常驻 + 原生设置窗口(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)
70 lines
1.7 KiB
Go
70 lines
1.7 KiB
Go
// 系统交互封装:打开路径/URL、带参启动进程、启动期消息框。
|
|
package windows
|
|
|
|
import (
|
|
"fmt"
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
const (
|
|
swShowNormal = 1
|
|
mbIconInformation = 0x00000040
|
|
)
|
|
|
|
var (
|
|
procShellExecuteW = syscall.NewLazyDLL("shell32.dll").NewProc("ShellExecuteW")
|
|
procMessageBoxW = syscall.NewLazyDLL("user32.dll").NewProc("MessageBoxW")
|
|
)
|
|
|
|
// OpenPath 用系统默认关联打开路径或 URL(无参数)。
|
|
func OpenPath(path string) error {
|
|
return OpenPathWithArgs(path, "")
|
|
}
|
|
|
|
// 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
|
|
}
|
|
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
|
|
}
|
|
|
|
// 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)
|
|
}
|