//go:build windows package platform import ( "os" "sync" toast "git.sr.ht/~jackmordaunt/go-toast/v2" ) const ( // toastAppID 是 Windows Action Center 里显示的应用标识,与 macOS bundle id 对齐。 toastAppID = "net.commilitia.cdrop" // toastGUID 固定不变——它把通知归属到注册表里的本应用条目;更换会让既有通知 // 失去归属。 toastGUID = "{c4d8e2a1-6b3f-4e7a-9c2d-1f5b8a0e3d6c}" ) var toastInit sync.Once // Notify shows a native Windows toast. go-toast renders via the WinRT/COM path // (PowerShell fallback when the AppID isn't registered), so it works without code // signing — SmartScreen only gates the installer, not notifications. Best-effort: // errors are swallowed. SetAppData registers the app identity once so the toast // shows "cdrop" rather than the PowerShell host. func Notify(title, body string) { toastInit.Do(func() { data := toast.AppData{AppID: toastAppID, GUID: toastGUID} if exe, err := os.Executable(); err == nil { data.ActivationExe = exe } _ = toast.SetAppData(data) }) n := toast.Notification{ AppID: toastAppID, Title: title, Body: body, } _ = n.Push() }