mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
- 新增 AlertWindowsApi 结构体和 SendNotification 方法,用于发送 Windows 系统通知 - 实现 SendDingDingMessageByType 方法,支持根据不同消息类型发送通知 - 添加消息类型 TTL 和名称映射,优化消息发送逻辑 - 更新前端接口,增加 SendDingDingMessageByType 方法调用- 引入 go-toast 库,用于 Windows 系统通知
31 lines
598 B
Go
31 lines
598 B
Go
//go:build windows
|
|
|
|
package data
|
|
|
|
import (
|
|
"github.com/go-toast/toast"
|
|
"go-stock/backend/logger"
|
|
"testing"
|
|
)
|
|
|
|
// @Author spark
|
|
// @Date 2025/1/8 9:40
|
|
// @Desc
|
|
//-----------------------------------------------------------------------------------
|
|
|
|
func TestAlert(t *testing.T) {
|
|
notification := toast.Notification{
|
|
AppID: "go-stock",
|
|
Title: "Hello, World!",
|
|
Message: "This is a toast notification.",
|
|
Icon: "../../build/appicon.png",
|
|
Duration: "short",
|
|
Audio: toast.Default,
|
|
}
|
|
err := notification.Push()
|
|
if err != nil {
|
|
logger.SugaredLogger.Error(err)
|
|
return
|
|
}
|
|
}
|