项目地址:fyne-io/systray: a cross platfrom Go library to place an icon and menu in the notification area
这是一个用golang开发托盘程序的包,很多同学想要开发一个简单的桌面程序但又不想大费周章学习swift、.net等原生开发,也不想为了一个小功能去用flutter、electron、tauri这种重量级项目
而fyne.io/systray
刚好够用,直接在系统托盘放个按钮,把自己想要的功能发在菜单里,简单easy,而且golang本身支持跨平台编译,直接制作成macOs、Windows、Linux等多平台程序也是没问题的。
话不多说下面介绍使用方式,使用方式非常简单
package main
import "fyne.io/systray"
import "fyne.io/systray/example/icon"
func main() {
systray.Run(onReady, onExit)
}
func onReady() {
systray.SetIcon(icon.Data)
systray.SetTitle("Awesome App")
systray.SetTooltip("Pretty awesome超级棒")
mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
// Sets the icon of a menu item.
mQuit.SetIcon(icon.Data)
}
func onExit() {
// clean up here
}
想要了解更详细的内容,看这里: System Tray Menu | Fyne.io