diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 727cbbe..9f308eb 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,8 +2,11 @@ + + + @@ -40,14 +43,14 @@ - - + - - - + + + + diff --git a/controller/ConfigInfo.go b/controller/ConfigInfo.go index ff5a727..bb997b1 100644 --- a/controller/ConfigInfo.go +++ b/controller/ConfigInfo.go @@ -256,7 +256,7 @@ func updateConfig(Name, url string) error { return err } -func UserINFO() (UnUsedINFO, TotalINFO, ExpireINFO string) { +func UserINFO() (UsedINFO, UnUsedINFO, ExpireINFO string) { var ( infoURL = "" ) @@ -291,12 +291,13 @@ func UserINFO() (UnUsedINFO, TotalINFO, ExpireINFO string) { Expire, _ := strconv.ParseInt(info[4], 10, 64) tm := time.Unix(Expire, 0) Unused := Total - Upload - Download + Used := Upload + Download + UsedINFO := formatFileSize(Used) UnUsedINFO := formatFileSize(Unused) - TotalINFO := formatFileSize(Total) ExpireINFO := tm.Format("2006-01-02") - return UnUsedINFO, TotalINFO, ExpireINFO + return UsedINFO, UnUsedINFO, ExpireINFO } else { - return UnUsedINFO, TotalINFO, ExpireINFO + return UsedINFO, UnUsedINFO, ExpireINFO } } diff --git a/controller/Task.go b/controller/Task.go index 8e39a91..5247004 100644 --- a/controller/Task.go +++ b/controller/Task.go @@ -102,11 +102,10 @@ func TaskCommand(args string) error { } func TaskBuild() (xml []byte) { - taskComName := os.Args[0] taskWorkingPath, _ := os.Getwd() doc := etree.NewDocument() - doc.CreateProcInst("xml", `version="1.0" encoding="GBK"`) + doc.CreateProcInst("xml", `version="1.0" encoding="UTF-16"`) Task := doc.CreateElement(`Task`) Task.CreateAttr("version", "1.2") Task.CreateAttr("xmlns", `http://schemas.microsoft.com/windows/2004/02/mit/task`) diff --git a/notify/notify.go b/notify/notify.go index 60d4e5c..258b63c 100644 --- a/notify/notify.go +++ b/notify/notify.go @@ -19,27 +19,27 @@ func Notify(info string) { switch info { case "SysON": - content = "系统代理:✅" + content = "--------------------\n系统代理:✅" case "SysOFF": - content = "系统代理:❎" + content = "--------------------\n系统代理:❎" case "Direct": - content = "已切换为:直连模式-✅" + content = "--------------------\n已切换为:直连模式-✅" case "Rule": - content = "已切换为:规则模式-✅" + content = "--------------------\n已切换为:规则模式-✅" case "Global": - content = "已切换为:全局模式-✅" + content = "--------------------\n已切换为:全局模式-✅" case "Startup": - content = "开机启动:✅" + content = "--------------------\n开机启动:✅" case "StartupOff": - content = "开机启动:❎" + content = "--------------------\n开机启动:❎" case "SysAutoON": - content = "默认代理:✅" + content = "--------------------\n默认代理:✅" case "SysAutoOFF": - content = "默认代理:❎" + content = "--------------------\n默认代理:❎" case "Max": - content = "成功切换Maxmind数据库" + content = "--------------------\n成功切换:Maxmind数据库" case "Lite": - content = "成功切换Hackl0us数据库" + content = "--------------------\n成功切换:Hackl0us数据库" } notification := toast.Notification{ AppID: "Clash.Mini", @@ -52,8 +52,8 @@ func Notify(info string) { } } -func NotifyINFO(UnUsedINFO, TotalINFO, ExpireINFO string) { - content = "剩余流量:" + UnUsedINFO + "\n流量额度:" + TotalINFO + "\n到期时间:" + ExpireINFO +func NotifyINFO(UsedINFO, UnUsedINFO, ExpireINFO string) { + content = "--------------------\n已用流量:" + UsedINFO + "\n剩余流量:" + UnUsedINFO + "\n到期时间:" + ExpireINFO notification := toast.Notification{ AppID: "Clash.Mini", Title: "📢流量信息📢", diff --git a/systray/systray.go b/systray/systray.go index 1d29bcd..cb2328b 100644 --- a/systray/systray.go +++ b/systray/systray.go @@ -83,11 +83,6 @@ func onReady() { notify.Notify("SysON") } - UnUsedINFO, TotalINFO, ExpireINFO := controller.UserINFO() - if UnUsedINFO != "" { - notify.NotifyINFO(UnUsedINFO, TotalINFO, ExpireINFO) - } - for { <-t.C switch tunnel.Mode() { @@ -188,10 +183,16 @@ func onReady() { } else { } } + } }() go func() { + UnUsedINFO, TotalINFO, ExpireINFO := controller.UserINFO() + time.Sleep(2 * time.Second) + if UnUsedINFO != "" { + notify.NotifyINFO(UnUsedINFO, TotalINFO, ExpireINFO) + } for { select { case <-mTitle.ClickedCh: @@ -237,13 +238,13 @@ func onReady() { case <-mOtherAutosys.ClickedCh: if mOtherAutosys.Checked() { controller.Regcmd("Sys", "OFF") - time.Sleep(3 * time.Second) + time.Sleep(2 * time.Second) if controller.RegCompare("Sys") == false { notify.Notify("SysAutoOFF") } } else { controller.Regcmd("Sys", "ON") - time.Sleep(3 * time.Second) + time.Sleep(2 * time.Second) if controller.RegCompare("Sys") == true { notify.Notify("SysAutoON") } @@ -251,13 +252,13 @@ func onReady() { case <-mOtherTask.ClickedCh: if mOtherTask.Checked() { controller.TaskCommand("delete") - time.Sleep(3 * time.Second) + time.Sleep(2 * time.Second) if controller.RegCompare("Task") == false { notify.Notify("StartupOff") } } else { controller.TaskCommand("create") - time.Sleep(3 * time.Second) + time.Sleep(2 * time.Second) taskFile := filepath.Join(".", "task.xml") taskPath, _ := os.Getwd() Filepath := filepath.Join(taskPath, taskFile) @@ -271,7 +272,8 @@ func onReady() { return } else { controller.GetMMDB("Max") - if controller.RegCompare("MMBD") == true { + if controller.RegCompare("MMBD") == false { + time.Sleep(2 * time.Second) notify.Notify("Max") } } @@ -280,7 +282,8 @@ func onReady() { return } else { controller.GetMMDB("Lite") - if controller.RegCompare("MMBD") == false { + if controller.RegCompare("MMBD") == true { + time.Sleep(2 * time.Second) notify.Notify("Lite") } }