v2.3.63 darwin notice

This commit is contained in:
yanghy 2023-01-26 12:33:19 +08:00
parent 6b2fd16619
commit 261dbd4dd0
5 changed files with 20 additions and 6 deletions

View File

@ -91,10 +91,15 @@ func (m *SysTray) AsLCLTray() *LCLTray {
func (m *SysTray) Show() {
m.once.Do(func() {
if m.start == nil {
go func() {
var runLoop = func() {
m.start, m.stop = systray.RunWithExternalLoop(m.onReady, m.onExit)
m.start()
}()
}
if common.IsDarwin() {
runLoop()
} else {
go runLoop()
}
}
})
}

View File

@ -140,7 +140,7 @@ func sysTray(browserWindow cef.IBrowserWindow) {
check.Check()
} else {
sysTray.SetHint(fmt.Sprintf("%d\n%v", time.Now().Second(), b))
sysTray.SetIconFS("resources/icon.ico")
sysTray.SetIconFS("resources/icon.png")
menuItem.SetIconFS("resources/icon.ico")
enable.SetLabel(fmt.Sprintf("%d\n%v", time.Now().Second(), b))
enable.Disable()

View File

@ -10,7 +10,6 @@ package main
import (
"embed"
"energye/notice"
"fmt"
"github.com/energye/energy/cef"
"github.com/energye/energy/common"
@ -72,7 +71,7 @@ func main() {
//设置隐藏窗口标题
//window.HideTitle()
fmt.Println("SetBrowserInitAfter 结束")
sysTray(window)
//sysTray(window)
})
//在主进程启动成功之后执行
//在这里启动内置http服务
@ -102,7 +101,7 @@ func sysTray(browserWindow cef.IBrowserWindow) {
check.Check()
not := tray.AddMenuItem("通知")
not.Click(func() {
notice.SendNotification(notice.NewNotification("标题", "内容").SetIconFS("resources/icon.png"))
//notice.SendNotification(notice.NewNotification("标题", "内容").SetIconFS("resources/icon.png"))
})
enable := tray.AddMenuItem("启用/禁用")
enable.Click(func() {

View File

@ -0,0 +1,6 @@
package notice
/*
#cgo LDFLAGS: -framework Foundation -framework UserNotifications
*/
import "C"

View File

@ -1,3 +1,6 @@
//go:build darwin
// +build darwin
package notice
/*
@ -15,6 +18,7 @@ import (
"fmt"
"golang.org/x/sys/execabs"
"strings"
"unsafe"
)
func SendNotification(n *Notification) {