-
Notifications
You must be signed in to change notification settings - Fork 11
/
app_others.go
97 lines (77 loc) · 1.49 KB
/
app_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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//go:build !darwin
package main
import (
"context"
"github.com/metacubex/mihomo/log"
"pandora-box/backend/cache"
"pandora-box/backend/constant"
"pandora-box/backend/meta"
isadmin "pandora-box/backend/system/admin"
"pandora-box/backend/system/open"
"pandora-box/backend/system/update"
"runtime"
)
// App struct
type App struct {
ctx context.Context
addr string
apiOk bool
}
func NewApp(addr string) *App {
return &App{
addr: addr,
}
}
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
}
func (a *App) IsMac() string {
if runtime.GOOS == "darwin" {
return "true"
}
return "false"
}
func (a *App) GetMacAcStatus() string {
status, _ := GetAcStatus()
return status
}
func GetAcStatus() (string, string) {
return "1", ""
}
func (a *App) SetMacAc(pwd string) string {
return "1"
}
func (a *App) IsAdmin() string {
if isadmin.Check() {
return "true"
}
return "false"
}
func (a *App) GetFreePort() string {
return a.addr
}
func (a *App) GetSecret() string {
value := cache.Get(constant.SecretKey)
return string(value)
}
func (a *App) OpenConfigDirectory() {
_, err := open.OpenConfigDirectory()
if err != nil {
log.Errorln("OpenConfigDirectory error:", err)
}
}
func (a *App) IsUnifiedDelay() string {
meta.StartLock.Lock()
defer meta.StartLock.Unlock()
if meta.NowConfig.General.UnifiedDelay {
return "true"
}
return "false"
}
func (a *App) IsNeedUpdate() string {
needUpdate, _ := update.IsNeedUpdate()
if needUpdate {
return "true"
}
return "false"
}