diff --git a/util/common/format.go b/util/common/format.go index 145669084c..1ea108776d 100644 --- a/util/common/format.go +++ b/util/common/format.go @@ -1,21 +1,21 @@ package common import ( - "fmt" + "fmt" ) func FormatTraffic(trafficBytes int64) (size string) { - if trafficBytes < 1024 { - return fmt.Sprintf("%.2fB", float64(trafficBytes)/float64(1)) - } else if trafficBytes < (1024 * 1024) { - return fmt.Sprintf("%.2fKB", float64(trafficBytes)/float64(1024)) - } else if trafficBytes < (1024 * 1024 * 1024) { - return fmt.Sprintf("%.2fMB", float64(trafficBytes)/float64(1024*1024)) - } else if trafficBytes < (1024 * 1024 * 1024 * 1024) { - return fmt.Sprintf("%.2fGB", float64(trafficBytes)/float64(1024*1024*1024)) - } else if trafficBytes < (1024 * 1024 * 1024 * 1024 * 1024) { - return fmt.Sprintf("%.2fTB", float64(trafficBytes)/float64(1024*1024*1024*1024)) - } else { - return fmt.Sprintf("%.2fEB", float64(trafficBytes)/float64(1024*1024*1024*1024*1024)) - } + if trafficBytes < 1024 { + return fmt.Sprintf("%.2fB", float64(trafficBytes)/float64(1)) + } else if trafficBytes < (1024 * 1024) { + return fmt.Sprintf("%.2fKB", float64(trafficBytes)/float64(1024)) + } else if trafficBytes < (1024 * 1024 * 1024) { + return fmt.Sprintf("%.2fMB", float64(trafficBytes)/float64(1024*1024)) + } else if trafficBytes < (1024 * 1024 * 1024 * 1024) { + return fmt.Sprintf("%.2fGB", float64(trafficBytes)/float64(1024*1024*1024)) + } else if trafficBytes < (1024 * 1024 * 1024 * 1024 * 1024) { + return fmt.Sprintf("%.2fTB", float64(trafficBytes)/float64(1024*1024*1024*1024)) + } else { + return fmt.Sprintf("%.2fEB", float64(trafficBytes)/float64(1024*1024*1024*1024*1024)) + } } diff --git a/web/assets/js/model/models.js b/web/assets/js/model/models.js index e00e05655b..d15afdc67b 100644 --- a/web/assets/js/model/models.js +++ b/web/assets/js/model/models.js @@ -163,6 +163,7 @@ class AllSetting { this.webCertFile = ""; this.webKeyFile = ""; this.webBasePath = "/"; + this.tgBotEnable = false; this.tgBotToken = ""; this.tgBotChatId = 0; this.tgRunTime = ""; diff --git a/web/entity/entity.go b/web/entity/entity.go index 9f7bfa04a8..f8572f665c 100644 --- a/web/entity/entity.go +++ b/web/entity/entity.go @@ -32,6 +32,7 @@ type AllSetting struct { WebCertFile string `json:"webCertFile" form:"webCertFile"` WebKeyFile string `json:"webKeyFile" form:"webKeyFile"` WebBasePath string `json:"webBasePath" form:"webBasePath"` + TgBotEnable bool `json:"tgBotEnable" form:"tgBotEnable"` TgBotToken string `json:"tgBotToken" form:"tgBotToken"` TgBotChatId int `json:"tgBotChatId" form:"tgBotChatId"` TgRunTime string `json:"tgRunTime" form:"tgRunTime"` diff --git a/web/html/xui/component/setting.html b/web/html/xui/component/setting.html index 7b8b26362c..9f8e8cbcdd 100644 --- a/web/html/xui/component/setting.html +++ b/web/html/xui/component/setting.html @@ -14,6 +14,9 @@ + diff --git a/web/html/xui/setting.html b/web/html/xui/setting.html index 1082f5a7a8..c48a8ab7cf 100644 --- a/web/html/xui/setting.html +++ b/web/html/xui/setting.html @@ -73,9 +73,10 @@ + - + diff --git a/web/service/setting.go b/web/service/setting.go index 88f1675999..2f9020de61 100644 --- a/web/service/setting.go +++ b/web/service/setting.go @@ -83,6 +83,8 @@ func (s *SettingService) GetAllSetting() (*entity.AllSetting, error) { fieldV.SetInt(n) case string: fieldV.SetString(value) + case bool: + fieldV.SetBool(value == "true") default: return common.NewErrorf("unknown field %v type %v", key, t) }