-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
68 lines (59 loc) · 1.2 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"Hi/client"
_ "embed"
"fmt"
"github.com/getlantern/systray"
)
//go:embed icon/Hi.ico
var ic []byte
func main() {
systray.Run(onReady, onExit)
}
func onReady() {
systray.SetIcon(ic)
systray.SetTitle("Hi")
systray.SetTooltip("Hi")
mCore := systray.AddMenuItem("主程序", "重新选择主程序")
mConf := systray.AddMenuItem("配置", "重新选择配置文件")
mReStart := systray.AddMenuItem("重启", "重启")
mQuit := systray.AddMenuItem("退出", "退出")
go func() {
client.AppCmd.CheckPath()
client.AppCmd.Start()
}()
go func() {
for {
select {
case <-mQuit.ClickedCh:
go func() {
client.AppCmd.Stop()
client.AppCmd.DbClose()
}()
systray.Quit()
fmt.Println("Requesting quit")
fmt.Println("Finished quitting")
return
case <-mCore.ClickedCh:
go func() {
client.AppCmd.ReCore()
client.AppCmd.ReStart()
}()
case <-mConf.ClickedCh:
go func() {
client.AppCmd.ReConf()
client.AppCmd.ReStart()
}()
case <-mReStart.ClickedCh:
go func() {
client.AppCmd.ReStart()
}()
}
}
}()
}
func onExit() {
client.AppCmd.Stop()
client.AppCmd.DbClose()
fmt.Println("exiting ...")
}