From dfc6b5632732a523bb766e1448dda59cfda7296b Mon Sep 17 00:00:00 2001
From: vaxilu <47310637+vaxilu@users.noreply.github.com>
Date: Tue, 19 Apr 2022 12:12:37 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E9=A1=B5=E7=AB=AF=E8=AE=BE=E7=BD=AE?=
=?UTF-8?q?=E7=94=B5=E6=8A=A5=E6=9C=BA=E5=99=A8=E4=BA=BA=E5=BC=80=E5=85=B3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
util/common/format.go | 28 ++++++++++++++--------------
web/assets/js/model/models.js | 1 +
web/entity/entity.go | 1 +
web/html/xui/component/setting.html | 3 +++
web/html/xui/setting.html | 3 ++-
web/service/setting.go | 2 ++
6 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/util/common/format.go b/util/common/format.go
index 14566908..1ea10877 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 e00e0565..d15afdc6 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 9f7bfa04..f8572f66 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 7b8b2636..9f8e8cbc 100644
--- a/web/html/xui/component/setting.html
+++ b/web/html/xui/component/setting.html
@@ -14,6 +14,9 @@
+
+ $emit('input', value)">
+
diff --git a/web/html/xui/setting.html b/web/html/xui/setting.html
index 1082f5a7..c48a8ab7 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 88f16759..2f9020de 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)
}