go-stock/backend/data/alert_windows_api.go
ArvinLovegood 3402f0d296 feat(data):实现浏览器实例池化
- 新增 BrowserPool 结构和相关方法,用于管理和复用浏览器实例
- 在 CrawlerApi 中集成浏览器池,使用 FetchPage 方法获取页面内容
-优化了配置获取方式,统一使用 GetConfig() 函数
-修复了一些代码中的小问题,如错误处理和日志记录
2025-03-31 23:08:09 +08:00

54 lines
1.0 KiB
Go

//go:build windows
package data
import (
"github.com/go-toast/toast"
"go-stock/backend/logger"
)
// AlertWindowsApi @Author spark
// @Date 2025/1/8 9:40
// @Desc
// -----------------------------------------------------------------------------------
type AlertWindowsApi struct {
AppID string
// 窗口标题
Title string
// 窗口内容
Content string
// 窗口图标
Icon string
}
func NewAlertWindowsApi(AppID string, Title string, Content string, Icon string) *AlertWindowsApi {
return &AlertWindowsApi{
AppID: AppID,
Title: Title,
Content: Content,
Icon: Icon,
}
}
func (a AlertWindowsApi) SendNotification() bool {
if GetConfig().LocalPushEnable == false {
logger.SugaredLogger.Error("本地推送未开启")
return false
}
notification := toast.Notification{
AppID: a.AppID,
Title: a.Title,
Message: a.Content,
Icon: a.Icon,
Duration: "short",
Audio: toast.Default,
}
err := notification.Push()
if err != nil {
logger.SugaredLogger.Error(err)
return false
}
return true
}