Browse Source

阿萨

master
VIVIMAN 3 years ago
parent
commit
b7f3619741
  1. 41
      golang_learn/data_func/go_to_tray/demo04/main.go

41
golang_learn/data_func/go_to_tray/demo04/main.go

@ -9,10 +9,37 @@ import (
"runtime"
)
var tab tableName
type tableName struct {
name11 string
name12 string
name21 string
name22 string
name31 string
name32 string
}
func main() {
initRun()
_ = systray.Run(onReady, onExit)
}
// 初始化设置名称
func initRun() {
switch runtime.GOOS {
case "windows":
tab = tableName{
name11: "启动", name12: "停止", name21: "启动", name22: "停止", name31: "升级", name32: "配置文件",
}
default: // "linux", "freebsd", "openbsd", "netbsd", "mac"
tab = tableName{
name11: "数据服务-启动", name12: "数据服务-停止", name21: "应用服务-启动",
name22: "应用服务-停止", name31: "帮助-升级", name32: "帮助-配置文件",
}
}
}
func mkFile() {
// 创建文件夹
err := os.Mkdir("shell", os.ModePerm)
@ -41,20 +68,20 @@ func onReady() {
timezone := "公务员"
_ = systray.SetTitle(timezone)
_ = systray.SetTooltip(timezone)
_ = systray.SetIcon(getIcon("/Users/zhangxianwei/GolandProjects/golangs_learn/golang_learn/data_func/go_to_tray/demo04/main.ico"))
_ = systray.SetIcon(getIcon("/home/hongyun/IdeaProjects/demo/main.ico"))
dbMenu := systray.AddSubMenu("数据服务")
startDbMenu := dbMenu.AddSubMenuItem("启动", "启动 - 数据库服务", 0)
stopDbMenu := dbMenu.AddSubMenuItem("停止", "停止 - 数据库服务", 0)
startDbMenu := dbMenu.AddSubMenuItem(tab.name11, "启动 - 数据库服务", 0)
stopDbMenu := dbMenu.AddSubMenuItem(tab.name12, "停止 - 数据库服务", 0)
cxMenu := systray.AddSubMenu("应用服务")
startCxMenu := cxMenu.AddSubMenuItem("启动", "启动 - 应用服务", 0)
stopCxMenu := cxMenu.AddSubMenuItem("停止", "停止 - 应用服务", 0)
startCxMenu := cxMenu.AddSubMenuItem(tab.name21, "启动 - 应用服务", 0)
stopCxMenu := cxMenu.AddSubMenuItem(tab.name22, "停止 - 应用服务", 0)
openMenu := systray.AddMenuItem("打开应用", "打开应用", 0)
submenu := systray.AddSubMenu("帮助")
upCxMenu := submenu.AddSubMenuItem("升级", "进行下载安装组工软件", 0)
infoMenu := submenu.AddSubMenuItem("配置文件", "创建配置文件", 0)
upCxMenu := submenu.AddSubMenuItem(tab.name31, "进行下载安装组工软件", 0)
infoMenu := submenu.AddSubMenuItem(tab.name32, "创建配置文件", 0)
systray.AddSeparator()
mQuit := systray.AddMenuItem("退出", "退出", 0)

Loading…
Cancel
Save