feat: 细化配置文件,不兼容性更新
This commit is contained in:
@@ -16,7 +16,7 @@ type daemon struct {
|
||||
|
||||
var Daemon = daemon{
|
||||
Mark: fmt.Sprint(time.Now().UnixNano()),
|
||||
Path: ".autoLoginDaemon",
|
||||
Path: global.Config.Settings.Daemon.Path,
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -35,7 +35,7 @@ func Guardian(output bool) {
|
||||
c <- false
|
||||
}()
|
||||
<-c
|
||||
time.Sleep(time.Duration(global.Config.Settings.Guardian) * time.Second)
|
||||
time.Sleep(time.Duration(global.Config.Settings.Guardian.Duration) * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func EnterGuardian() {
|
||||
global.Status.Output = true
|
||||
global.Status.Guardian = true
|
||||
util.Log.Println("[Guardian mode]")
|
||||
if global.Config.Settings.Daemon {
|
||||
if global.Config.Settings.Daemon.Enable {
|
||||
if err := exec.Command(os.Args[0], "-daemon").Start(); err != nil {
|
||||
util.Log.Fatalln(err)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ func init() {
|
||||
if e := config.Load(config.Options{
|
||||
Config: &Config,
|
||||
Default: &models.Config{
|
||||
From: models.LoginForm{
|
||||
Form: models.LoginForm{
|
||||
Domain: "www.msftconnecttest.com",
|
||||
UserType: "cmcc",
|
||||
},
|
||||
@@ -28,6 +28,12 @@ func init() {
|
||||
},
|
||||
Settings: models.Settings{
|
||||
Timeout: 1,
|
||||
Daemon: models.Daemon{
|
||||
Path: ".autoLogin",
|
||||
},
|
||||
Guardian: models.Guardian{
|
||||
Duration: 300,
|
||||
},
|
||||
},
|
||||
},
|
||||
Path: Flags.Path,
|
||||
|
||||
2
main.go
2
main.go
@@ -9,7 +9,7 @@ import (
|
||||
func main() {
|
||||
defer util.Log.CatchRecover()
|
||||
|
||||
if global.Config.Settings.Guardian != 0 {
|
||||
if global.Config.Settings.Guardian.Enable {
|
||||
controllers.EnterGuardian()
|
||||
} else if err := controllers.Login(true, false); err != nil {
|
||||
util.Log.Println("运行出错,状态异常")
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
package models
|
||||
|
||||
type Daemon struct {
|
||||
Enable bool `json:"enable"`
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
type Guardian struct {
|
||||
Enable bool `json:"enable"`
|
||||
Duration uint `json:"duration"`
|
||||
}
|
||||
|
||||
type Settings struct {
|
||||
Timeout uint `json:"timeout"`
|
||||
DemoMode bool `json:"demo_mode"`
|
||||
Guardian uint `json:"guardian"`
|
||||
Daemon bool `json:"daemon"`
|
||||
Guardian Guardian
|
||||
Daemon Daemon
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
|
||||
Reference in New Issue
Block a user