diff --git a/golang_learn/data_func/go_to_tray/demo01/main.go b/golang_learn/data_func/go_to_tray/demo01/main.go index 0c95200..268a783 100644 --- a/golang_learn/data_func/go_to_tray/demo01/main.go +++ b/golang_learn/data_func/go_to_tray/demo01/main.go @@ -20,7 +20,7 @@ func main() { func onReady() { timezone = "默认文字" - systray.SetIcon(getIcon("D:\\ViviCode\\golangs_learn\\golang_learn\\data_func\\go_to_tray\\demo01\\icon.ico")) + systray.SetIcon(getIcon("/Users/zhangxianwei/GolandProjects/golangs_learn/golang_learn/data_func/go_to_tray/demo01/icon.ico")) submenu := systray.AddSubMenu("子菜单") _ = submenu.AddSubMenuItem("开始", "", 0) diff --git a/golang_learn/data_func/go_to_tray/demo04/.keepgit b/golang_learn/data_func/go_to_tray/demo04/.keepgit deleted file mode 100644 index d2bd535..0000000 --- a/golang_learn/data_func/go_to_tray/demo04/.keepgit +++ /dev/null @@ -1 +0,0 @@ -增加版本控制 \ No newline at end of file diff --git a/golang_learn/data_func/go_to_tray/demo04/build.bat b/golang_learn/data_func/go_to_tray/demo04/build.bat new file mode 100644 index 0000000..b4079df --- /dev/null +++ b/golang_learn/data_func/go_to_tray/demo04/build.bat @@ -0,0 +1,7 @@ +set GO111MODULE=on +SET CGO_ENABLED=0 +set GOARCH=386 +set GOOS=windows +rsrc -manifest main.manifest -ico main.ico -o main.syso +go generate +go build -ldflags="-s -w -H=windowsgui" -o ˵-м.exe diff --git a/golang_learn/data_func/go_to_tray/demo03/run.bat b/golang_learn/data_func/go_to_tray/demo04/build.sh similarity index 77% rename from golang_learn/data_func/go_to_tray/demo03/run.bat rename to golang_learn/data_func/go_to_tray/demo04/build.sh index 3ae25dc..b44aae5 100644 --- a/golang_learn/data_func/go_to_tray/demo03/run.bat +++ b/golang_learn/data_func/go_to_tray/demo04/build.sh @@ -1,6 +1,5 @@ -set GO111MODULE=on SET CGO_ENABLED=0 -set GOARCH=arm +set GOARCH=amd set GOOS=linux rsrc -manifest main.manifest -ico main.ico -o main.syso go generate diff --git a/golang_learn/data_func/go_to_tray/demo04/main.go b/golang_learn/data_func/go_to_tray/demo04/main.go new file mode 100644 index 0000000..dc8fe9c --- /dev/null +++ b/golang_learn/data_func/go_to_tray/demo04/main.go @@ -0,0 +1,55 @@ +package main + +import ( + "fmt" + "github.com/riftbit/go-systray" + "io/ioutil" +) + +var ( + timezone string +) + +func main() { + systray.Run(onReady, onExit) +} + +func onReady() { + timezone = "公务员" + _ = systray.SetIcon(getIcon("/Users/zhangxianwei/GolandProjects/golangs_learn/golang_learn/data_func/go_to_tray/demo01/icon.ico")) + + submenu := systray.AddSubMenu("子菜单") + _ = submenu.AddSubMenuItem("开始", "", 0) + _ = submenu.AddSubMenuItem("结束", "", 0) + + localTime := systray.AddMenuItem("炎龙", "炎龙", 0) + + fmt.Printf("%#v", localTime) + + systray.AddSeparator() + mQuit := systray.AddMenuItem("退出", "退出", 0) + + go func() { + for { + select { + case <-localTime.OnClickCh(): + timezone = "炎龙" + case <-mQuit.OnClickCh(): + systray.Quit() + return + } + } + }() +} + +func onExit() { + // 清除销毁 +} + +func getIcon(s string) []byte { + b, err := ioutil.ReadFile(s) + if err != nil { + fmt.Print(err) + } + return b +} diff --git a/golang_learn/data_func/go_to_tray/demo04/main.ico b/golang_learn/data_func/go_to_tray/demo04/main.ico new file mode 100644 index 0000000..758a8d4 Binary files /dev/null and b/golang_learn/data_func/go_to_tray/demo04/main.ico differ diff --git a/golang_learn/data_func/go_to_tray/demo04/main.manifest b/golang_learn/data_func/go_to_tray/demo04/main.manifest new file mode 100644 index 0000000..4a042b0 --- /dev/null +++ b/golang_learn/data_func/go_to_tray/demo04/main.manifest @@ -0,0 +1,22 @@ + + + + + + + + + + + PerMonitorV2, PerMonitor + True + + + + + + + + + + \ No newline at end of file diff --git a/golang_learn/data_func/go_to_tray/demo04/main.syso b/golang_learn/data_func/go_to_tray/demo04/main.syso new file mode 100644 index 0000000..a47c9ab Binary files /dev/null and b/golang_learn/data_func/go_to_tray/demo04/main.syso differ diff --git a/golang_learn/data_func/go_to_tray/demo04/shell/closeCX.bat b/golang_learn/data_func/go_to_tray/demo04/shell/closeCX.bat new file mode 100644 index 0000000..07603f8 --- /dev/null +++ b/golang_learn/data_func/go_to_tray/demo04/shell/closeCX.bat @@ -0,0 +1 @@ +net stop GWY20_Tomcat \ No newline at end of file diff --git a/golang_learn/data_func/go_to_tray/demo04/shell/closeCX.sh b/golang_learn/data_func/go_to_tray/demo04/shell/closeCX.sh new file mode 100644 index 0000000..f88041a --- /dev/null +++ b/golang_learn/data_func/go_to_tray/demo04/shell/closeCX.sh @@ -0,0 +1 @@ +net start GWY20_Mysql \ No newline at end of file diff --git a/golang_learn/data_func/go_to_tray/demo04/shell/closeDB.bat b/golang_learn/data_func/go_to_tray/demo04/shell/closeDB.bat new file mode 100644 index 0000000..c8e402e --- /dev/null +++ b/golang_learn/data_func/go_to_tray/demo04/shell/closeDB.bat @@ -0,0 +1 @@ +net stop GWY20_Mysql \ No newline at end of file diff --git a/golang_learn/data_func/go_to_tray/demo04/shell/closeDB.sh b/golang_learn/data_func/go_to_tray/demo04/shell/closeDB.sh new file mode 100644 index 0000000..f88041a --- /dev/null +++ b/golang_learn/data_func/go_to_tray/demo04/shell/closeDB.sh @@ -0,0 +1 @@ +net start GWY20_Mysql \ No newline at end of file diff --git a/golang_learn/data_func/go_to_tray/demo04/shell/startCX.bat b/golang_learn/data_func/go_to_tray/demo04/shell/startCX.bat new file mode 100644 index 0000000..9348e8d --- /dev/null +++ b/golang_learn/data_func/go_to_tray/demo04/shell/startCX.bat @@ -0,0 +1 @@ +net start GWY20_Tomcat \ No newline at end of file diff --git a/golang_learn/data_func/go_to_tray/demo04/shell/startCX.sh b/golang_learn/data_func/go_to_tray/demo04/shell/startCX.sh new file mode 100644 index 0000000..f88041a --- /dev/null +++ b/golang_learn/data_func/go_to_tray/demo04/shell/startCX.sh @@ -0,0 +1 @@ +net start GWY20_Mysql \ No newline at end of file diff --git a/golang_learn/data_func/go_to_tray/demo04/shell/startDB.bat b/golang_learn/data_func/go_to_tray/demo04/shell/startDB.bat new file mode 100644 index 0000000..f88041a --- /dev/null +++ b/golang_learn/data_func/go_to_tray/demo04/shell/startDB.bat @@ -0,0 +1 @@ +net start GWY20_Mysql \ No newline at end of file diff --git a/golang_learn/data_func/go_to_tray/demo04/shell/startDB.sh b/golang_learn/data_func/go_to_tray/demo04/shell/startDB.sh new file mode 100644 index 0000000..f88041a --- /dev/null +++ b/golang_learn/data_func/go_to_tray/demo04/shell/startDB.sh @@ -0,0 +1 @@ +net start GWY20_Mysql \ No newline at end of file