-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
tray_others.go
75 lines (61 loc) · 1.4 KB
/
tray_others.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
69
70
71
72
73
74
75
//go:build !windows && !darwin
// +build !windows,!darwin
package main
import (
"net"
"os"
"os/exec"
"regexp"
"runtime"
"syscall"
"github.com/labstack/echo/v4"
"sealdice-core/dice"
log "sealdice-core/utils/kratos"
)
func trayInit(dm *dice.DiceManager) {
select {}
}
func hideWindow() {
}
func showWindow() {
}
func TestRunning() bool {
return false
}
func tempDirWarn() {
log.Warn("当前工作路径为临时目录,因此拒绝继续执行。")
}
func showMsgBox(title string, message string) {
log.Info(title, message)
}
func httpServe(e *echo.Echo, dm *dice.DiceManager, hideUI bool) {
portStr := "3211"
rePort := regexp.MustCompile(`:(\d+)$`)
m := rePort.FindStringSubmatch(dm.ServeAddress)
if len(m) > 0 {
portStr = m[1]
}
ln, err := net.Listen("tcp", ":"+portStr)
if err != nil {
log.Errorf("端口已被占用,即将自动退出: %s", dm.ServeAddress)
runtime.Goexit()
}
_ = ln.Close()
log.Infof("如果浏览器没有自动打开,请手动访问:\nhttp://localhost:%s", portStr)
err = e.Start(dm.ServeAddress)
if err != nil {
log.Errorf("端口已被占用,即将自动退出: %s", dm.ServeAddress)
return
}
}
func executeWin(name string, arg ...string) *exec.Cmd {
cmd := exec.Command(name, arg...)
cmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: true,
Pgid: os.Getppid(),
}
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
cmd.Stdin = os.Stdin
return cmd
}