From 2d4b1aafa752147b3694ae95b2a3226c7ad33bfb Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 Feb 2025 11:25:26 +0100 Subject: [PATCH] Add Setting entity + GUI field in panel settings --- web/assets/js/model/setting.js | 2 + web/entity/entity.go | 84 ++++++++++++++-------------- web/html/xui/settings.html | 3 + web/translation/translate.en_US.toml | 4 ++ web/translation/translate.fa_IR.toml | 4 ++ 5 files changed, 56 insertions(+), 41 deletions(-) diff --git a/web/assets/js/model/setting.js b/web/assets/js/model/setting.js index 8e010598..43046019 100644 --- a/web/assets/js/model/setting.js +++ b/web/assets/js/model/setting.js @@ -31,6 +31,8 @@ class AllSetting { this.subPath = "/sub/"; this.subJsonPath = "/json/"; this.subDomain = ""; + this.externalInformEnable = false; + this.externalTrafficInformURI = ""; this.subCertFile = ""; this.subKeyFile = ""; this.subUpdates = 12; diff --git a/web/entity/entity.go b/web/entity/entity.go index 12206340..82cc3e24 100644 --- a/web/entity/entity.go +++ b/web/entity/entity.go @@ -16,47 +16,49 @@ type Msg struct { } type AllSetting struct { - WebListen string `json:"webListen" form:"webListen"` - WebDomain string `json:"webDomain" form:"webDomain"` - WebPort int `json:"webPort" form:"webPort"` - WebCertFile string `json:"webCertFile" form:"webCertFile"` - WebKeyFile string `json:"webKeyFile" form:"webKeyFile"` - WebBasePath string `json:"webBasePath" form:"webBasePath"` - SessionMaxAge int `json:"sessionMaxAge" form:"sessionMaxAge"` - PageSize int `json:"pageSize" form:"pageSize"` - ExpireDiff int `json:"expireDiff" form:"expireDiff"` - TrafficDiff int `json:"trafficDiff" form:"trafficDiff"` - RemarkModel string `json:"remarkModel" form:"remarkModel"` - TgBotEnable bool `json:"tgBotEnable" form:"tgBotEnable"` - TgBotToken string `json:"tgBotToken" form:"tgBotToken"` - TgBotProxy string `json:"tgBotProxy" form:"tgBotProxy"` - TgBotAPIServer string `json:"tgBotAPIServer" form:"tgBotAPIServer"` - TgBotChatId string `json:"tgBotChatId" form:"tgBotChatId"` - TgRunTime string `json:"tgRunTime" form:"tgRunTime"` - TgBotBackup bool `json:"tgBotBackup" form:"tgBotBackup"` - TgBotLoginNotify bool `json:"tgBotLoginNotify" form:"tgBotLoginNotify"` - TgCpu int `json:"tgCpu" form:"tgCpu"` - TgLang string `json:"tgLang" form:"tgLang"` - TimeLocation string `json:"timeLocation" form:"timeLocation"` - SecretEnable bool `json:"secretEnable" form:"secretEnable"` - SubEnable bool `json:"subEnable" form:"subEnable"` - SubListen string `json:"subListen" form:"subListen"` - SubPort int `json:"subPort" form:"subPort"` - SubPath string `json:"subPath" form:"subPath"` - SubDomain string `json:"subDomain" form:"subDomain"` - SubCertFile string `json:"subCertFile" form:"subCertFile"` - SubKeyFile string `json:"subKeyFile" form:"subKeyFile"` - SubUpdates int `json:"subUpdates" form:"subUpdates"` - SubEncrypt bool `json:"subEncrypt" form:"subEncrypt"` - SubShowInfo bool `json:"subShowInfo" form:"subShowInfo"` - SubURI string `json:"subURI" form:"subURI"` - SubJsonPath string `json:"subJsonPath" form:"subJsonPath"` - SubJsonURI string `json:"subJsonURI" form:"subJsonURI"` - SubJsonFragment string `json:"subJsonFragment" form:"subJsonFragment"` - SubJsonNoises string `json:"subJsonNoises" form:"subJsonNoises"` - SubJsonMux string `json:"subJsonMux" form:"subJsonMux"` - SubJsonRules string `json:"subJsonRules" form:"subJsonRules"` - Datepicker string `json:"datepicker" form:"datepicker"` + WebListen string `json:"webListen" form:"webListen"` + WebDomain string `json:"webDomain" form:"webDomain"` + WebPort int `json:"webPort" form:"webPort"` + WebCertFile string `json:"webCertFile" form:"webCertFile"` + WebKeyFile string `json:"webKeyFile" form:"webKeyFile"` + WebBasePath string `json:"webBasePath" form:"webBasePath"` + SessionMaxAge int `json:"sessionMaxAge" form:"sessionMaxAge"` + PageSize int `json:"pageSize" form:"pageSize"` + ExpireDiff int `json:"expireDiff" form:"expireDiff"` + TrafficDiff int `json:"trafficDiff" form:"trafficDiff"` + RemarkModel string `json:"remarkModel" form:"remarkModel"` + TgBotEnable bool `json:"tgBotEnable" form:"tgBotEnable"` + TgBotToken string `json:"tgBotToken" form:"tgBotToken"` + TgBotProxy string `json:"tgBotProxy" form:"tgBotProxy"` + TgBotAPIServer string `json:"tgBotAPIServer" form:"tgBotAPIServer"` + TgBotChatId string `json:"tgBotChatId" form:"tgBotChatId"` + TgRunTime string `json:"tgRunTime" form:"tgRunTime"` + TgBotBackup bool `json:"tgBotBackup" form:"tgBotBackup"` + TgBotLoginNotify bool `json:"tgBotLoginNotify" form:"tgBotLoginNotify"` + TgCpu int `json:"tgCpu" form:"tgCpu"` + TgLang string `json:"tgLang" form:"tgLang"` + TimeLocation string `json:"timeLocation" form:"timeLocation"` + SecretEnable bool `json:"secretEnable" form:"secretEnable"` + SubEnable bool `json:"subEnable" form:"subEnable"` + SubListen string `json:"subListen" form:"subListen"` + SubPort int `json:"subPort" form:"subPort"` + SubPath string `json:"subPath" form:"subPath"` + SubDomain string `json:"subDomain" form:"subDomain"` + SubCertFile string `json:"subCertFile" form:"subCertFile"` + SubKeyFile string `json:"subKeyFile" form:"subKeyFile"` + SubUpdates int `json:"subUpdates" form:"subUpdates"` + ExternalInformEnable bool `json:"externalInformEnable" form:"externalInformEnable"` + ExternalInformURI string `json:"externalTrafficInformURI" form:"externalTrafficInformURI"` + SubEncrypt bool `json:"subEncrypt" form:"subEncrypt"` + SubShowInfo bool `json:"subShowInfo" form:"subShowInfo"` + SubURI string `json:"subURI" form:"subURI"` + SubJsonPath string `json:"subJsonPath" form:"subJsonPath"` + SubJsonURI string `json:"subJsonURI" form:"subJsonURI"` + SubJsonFragment string `json:"subJsonFragment" form:"subJsonFragment"` + SubJsonNoises string `json:"subJsonNoises" form:"subJsonNoises"` + SubJsonMux string `json:"subJsonMux" form:"subJsonMux"` + SubJsonRules string `json:"subJsonRules" form:"subJsonRules"` + Datepicker string `json:"datepicker" form:"datepicker"` } func (s *AllSetting) CheckValid() error { diff --git a/web/html/xui/settings.html b/web/html/xui/settings.html index 9eff8bec..653a84a6 100644 --- a/web/html/xui/settings.html +++ b/web/html/xui/settings.html @@ -278,6 +278,9 @@ + + + diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml index 638d619e..28d87cb6 100644 --- a/web/translation/translate.en_US.toml +++ b/web/translation/translate.en_US.toml @@ -301,6 +301,10 @@ "subDomainDesc" = "The domain name for the subscription service. (leave blank to listen on all domains and IPs)" "subUpdates" = "Update Intervals" "subUpdatesDesc" = "The update intervals of the subscription URL in the client apps. (unit: hour)" +"externalTrafficInformEnable" = "Traffic External Inform" +"externalTrafficInformEnableDesc" = "Inform external API on every traffic update." +"externalTrafficInformURI" = "Traffic External Inform URI" +"externalTrafficInformURIDesc" = "Traffic updates will be posted to this URI." "subEncrypt" = "Encode" "subEncryptDesc" = "The returned content of subscription service will be Base64 encoded." "subShowInfo" = "Show Usage Info" diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml index 6219996d..75833069 100644 --- a/web/translation/translate.fa_IR.toml +++ b/web/translation/translate.fa_IR.toml @@ -301,6 +301,10 @@ "subDomainDesc" = "آدرس دامنه برای سرویس سابسکریپشن. برای گوش دادن به تمام دامنه‌ها و آی‌پی‌ها خالی‌بگذارید‌" "subUpdates" = "فاصله بروزرسانی‌ سابسکریپشن" "subUpdatesDesc" = "(فاصله مابین بروزرسانی در برنامه‌های کاربری. (واحد: ساعت" +"externalTrafficInformEnable" = "اطلاع رسانی خارجی مصرف ترافیک" +"externalTrafficInformEnableDesc" = "مصرف ترافیک به سرویس خارجی ارسال می شود" +"externalTrafficInformURI" = "لینک اطلاع رسانی خارجی مصرف ترافیک" +"externalTrafficInformURIDesc" = "ترافیک های مصرفی به این لینک هم ارسال می شود" "subEncrypt" = "کدگذاری" "subEncryptDesc" = "کدگذاری خواهدشد Base64 محتوای برگشتی سرویس سابسکریپشن برپایه" "subShowInfo" = "نمایش اطلاعات مصرف"