|
|
@ -44,7 +44,6 @@ func (mw *MyWindow) AddNotifyIcon() { |
|
|
|
|
|
|
|
// 其他快捷键
|
|
|
|
mw.addOther() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func init() { |
|
|
@ -63,7 +62,63 @@ func checkError(err error) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// open opens the specified URL in the default browser of the user.
|
|
|
|
// OpenServe 打开服务
|
|
|
|
func OpenServe(isDb bool) error { |
|
|
|
var cmd string |
|
|
|
var args []string |
|
|
|
|
|
|
|
switch runtime.GOOS { |
|
|
|
case "windows": |
|
|
|
if isDb { |
|
|
|
cmd = "cmd" |
|
|
|
args = []string{"/c", "./shell/startDB.bat"} |
|
|
|
} else { |
|
|
|
cmd = "/bin/sh" |
|
|
|
args = []string{"-c", "./shell/startDB.sh"} |
|
|
|
} |
|
|
|
default: // "linux", "freebsd", "openbsd", "netbsd", "mac"
|
|
|
|
if isDb { |
|
|
|
cmd = "cmd" |
|
|
|
args = []string{"/c", "./shell/startCX.bat"} |
|
|
|
} else { |
|
|
|
cmd = "/bin/sh" |
|
|
|
args = []string{"-c", "./shell/startCX.sh"} |
|
|
|
} |
|
|
|
} |
|
|
|
c := exec.Command(cmd, args...) |
|
|
|
c.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} |
|
|
|
return c.Start() |
|
|
|
} |
|
|
|
|
|
|
|
// CloseServe 停止服务
|
|
|
|
func CloseServe(isDb bool) error { |
|
|
|
var cmd string |
|
|
|
var args []string |
|
|
|
|
|
|
|
switch runtime.GOOS { |
|
|
|
case "windows": |
|
|
|
if isDb { |
|
|
|
cmd = "cmd" |
|
|
|
args = []string{"/c", "./shell/stopDB.bat"} |
|
|
|
} else { |
|
|
|
cmd = "/bin/sh" |
|
|
|
args = []string{"-c", "./shell/stopDB.sh"} |
|
|
|
} |
|
|
|
default: // "linux", "freebsd", "openbsd", "netbsd", "mac"
|
|
|
|
if isDb { |
|
|
|
cmd = "cmd" |
|
|
|
args = []string{"/c", "./shell/stopCX.bat"} |
|
|
|
} else { |
|
|
|
cmd = "/bin/sh" |
|
|
|
args = []string{"-c", "./shell/stopCX.sh"} |
|
|
|
} |
|
|
|
} |
|
|
|
c := exec.Command(cmd, args...) |
|
|
|
c.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} |
|
|
|
return c.Start() |
|
|
|
} |
|
|
|
|
|
|
|
// OpenUrl 按照地址打开浏览器,进行请求。
|
|
|
|
func OpenUrl(url string) error { |
|
|
|
var cmd string |
|
|
|
var args []string |
|
|
@ -72,9 +127,7 @@ func OpenUrl(url string) error { |
|
|
|
case "windows": |
|
|
|
cmd = "cmd" |
|
|
|
args = []string{"/c", "start"} |
|
|
|
case "darwin": |
|
|
|
cmd = "open" |
|
|
|
default: // "linux", "freebsd", "openbsd", "netbsd"
|
|
|
|
default: // "linux", "freebsd", "openbsd", "netbsd", "mac"
|
|
|
|
cmd = "xdg-open" |
|
|
|
} |
|
|
|
args = append(args, url) |
|
|
@ -172,11 +225,7 @@ func (mw *MyWindow) addCxMenu() { |
|
|
|
// AddListen 增加服务监听,控制按钮状态
|
|
|
|
func AddListen(startAction *walk.Action, stopAction *walk.Action, address string, timeout time.Duration) { |
|
|
|
conn, err := net.DialTimeout("tcp", address, timeout) |
|
|
|
if err != nil { |
|
|
|
// fmt.Println("["+now+"]", ipPort, "端口未开启(fail)!")
|
|
|
|
setEnableAndCheck(startAction, stopAction, false, false) |
|
|
|
} else { |
|
|
|
if conn != nil { |
|
|
|
if err == nil && conn != nil { |
|
|
|
// fmt.Println("["+now+"]", ipPort, "端口已开启(success)!")
|
|
|
|
setEnableAndCheck(startAction, stopAction, false, true) |
|
|
|
_ = conn.Close() |
|
|
@ -184,7 +233,6 @@ func AddListen(startAction *walk.Action, stopAction *walk.Action, address string |
|
|
|
// fmt.Println("["+now+"]", ipPort, "端口未开启(fail)!")
|
|
|
|
setEnableAndCheck(startAction, stopAction, true, false) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// setEnableAndCheck 设置按钮状态
|
|
|
|