diff --git a/cef/cef-tray-sys-commponent.go b/cef/cef-tray-sys-commponent.go index e3021e72..6c98417f 100644 --- a/cef/cef-tray-sys-commponent.go +++ b/cef/cef-tray-sys-commponent.go @@ -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() + } } }) } diff --git a/example/dev-test/lcl-browser/lcl-browser.go b/example/dev-test/lcl-browser/lcl-browser.go index 9b507d49..06a6b907 100644 --- a/example/dev-test/lcl-browser/lcl-browser.go +++ b/example/dev-test/lcl-browser/lcl-browser.go @@ -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() diff --git a/example/dev-test/vf-browser/vf-browser.go b/example/dev-test/vf-browser/vf-browser.go index e8e3ed4c..dc9eb665 100644 --- a/example/dev-test/vf-browser/vf-browser.go +++ b/example/dev-test/vf-browser/vf-browser.go @@ -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() { diff --git a/vendor/energye/notice/noteic_notlegacy_darwin.go b/vendor/energye/notice/noteic_notlegacy_darwin.go new file mode 100755 index 00000000..bbffa456 --- /dev/null +++ b/vendor/energye/notice/noteic_notlegacy_darwin.go @@ -0,0 +1,6 @@ +package notice + +/* +#cgo LDFLAGS: -framework Foundation -framework UserNotifications +*/ +import "C" diff --git a/vendor/energye/notice/notice_darwin.go b/vendor/energye/notice/notice_darwin.go index 52633148..c40bf33d 100644 --- a/vendor/energye/notice/notice_darwin.go +++ b/vendor/energye/notice/notice_darwin.go @@ -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) {