-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
58 lines (54 loc) · 1.32 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
package main
import (
"Go-YuJian/control"
fyne2 "Go-YuJian/fyne"
_ "Go-YuJian/io"
"Go-YuJian/utils"
"strings"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/dialog"
)
func main() {
window := fyne2.GetWindow()
// 加载图标
icon, _ := fyne.LoadResourceFromPath("./static/icon.png")
window.SetIcon(icon)
startBtn := fyne2.Btn.Start
stopBtn := fyne2.Btn.Stop
startBtn.OnTapped = func() {
if !utils.CheckURL(*fyne2.Input.URL) {
dialog.ShowInformation("EROOR", "URL无效,请重新填写", window)
return
}
if !utils.CheckDigits(*fyne2.Input.Thread) {
dialog.ShowInformation("EROOR", "线程数无效,请重新填写", window)
return
}
if !utils.CheckDigits(*fyne2.Input.Timeout) {
dialog.ShowInformation("EROOR", "超时时间无效,请重新填写", window)
return
}
if !strings.Contains(*fyne2.Input.URL, "://") {
dialog.ShowInformation("EROOR", "未指定URL协议", window)
return
}
if !utils.HostExists(utils.ExtractDomain(*fyne2.Input.URL)) {
dialog.ShowInformation("EROOR", "找不到URL主机", window)
return
}
startBtn.Disable()
stopBtn.Enable()
go func() {
control.StartWork()
stopBtn.Disable()
startBtn.Enable()
}()
}
stopBtn.OnTapped = func() {
control.StopWork()
stopBtn.Disable()
startBtn.Enable()
}
utils.SetMainWindows(window)
window.ShowAndRun()
}