diff --git a/web/controller/setting.go b/web/controller/setting.go index 96223c28..64cae71b 100644 --- a/web/controller/setting.go +++ b/web/controller/setting.go @@ -56,44 +56,11 @@ func (a *SettingController) getAllSetting(c *gin.Context) { } func (a *SettingController) getDefaultSettings(c *gin.Context) { - type settingFunc func() (interface{}, error) - - settings := map[string]settingFunc{ - "expireDiff": func() (interface{}, error) { return a.settingService.GetExpireDiff() }, - "trafficDiff": func() (interface{}, error) { return a.settingService.GetTrafficDiff() }, - "defaultCert": func() (interface{}, error) { return a.settingService.GetCertFile() }, - "defaultKey": func() (interface{}, error) { return a.settingService.GetKeyFile() }, - "tgBotEnable": func() (interface{}, error) { return a.settingService.GetTgbotenabled() }, - "subEnable": func() (interface{}, error) { return a.settingService.GetSubEnable() }, - "subPort": func() (interface{}, error) { return a.settingService.GetSubPort() }, - "subPath": func() (interface{}, error) { return a.settingService.GetSubPath() }, - "subDomain": func() (interface{}, error) { return a.settingService.GetSubDomain() }, - "subKeyFile": func() (interface{}, error) { return a.settingService.GetSubKeyFile() }, - "subCertFile": func() (interface{}, error) { return a.settingService.GetSubCertFile() }, - "subEncrypt": func() (interface{}, error) { return a.settingService.GetSubEncrypt() }, - "subShowInfo": func() (interface{}, error) { return a.settingService.GetSubShowInfo() }, + result, err := a.settingService.GetDefaultSettings(c.Request.Host) + if err != nil { + jsonMsg(c, I18nWeb(c, "pages.settings.toasts.getSettings"), err) + return } - - result := make(map[string]interface{}) - - for key, fn := range settings { - value, err := fn() - if err != nil { - jsonMsg(c, I18nWeb(c, "pages.settings.toasts.getSettings"), err) - return - } - result[key] = value - } - - subTLS := false - if result["subKeyFile"] != "" || result["subCertFile"] != "" { - subTLS = true - } - result["subTLS"] = subTLS - - delete(result, "subKeyFile") - delete(result, "subCertFile") - jsonObj(c, result, nil) } diff --git a/web/entity/entity.go b/web/entity/entity.go index 2c7b39ca..94f0171f 100644 --- a/web/entity/entity.go +++ b/web/entity/entity.go @@ -22,6 +22,7 @@ type AllSetting struct { 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"` TgBotEnable bool `json:"tgBotEnable" form:"tgBotEnable"` @@ -44,6 +45,7 @@ type AllSetting struct { SubUpdates int `json:"subUpdates" form:"subUpdates"` SubEncrypt bool `json:"subEncrypt" form:"subEncrypt"` SubShowInfo bool `json:"subShowInfo" form:"subShowInfo"` + SubURI string `json:"subURI" form:"subURI"` } func (s *AllSetting) CheckValid() error { @@ -93,6 +95,12 @@ func (s *AllSetting) CheckValid() error { if !strings.HasSuffix(s.WebBasePath, "/") { s.WebBasePath += "/" } + if !strings.HasPrefix(s.SubPath, "/") { + s.SubPath = "/" + s.SubPath + } + if !strings.HasSuffix(s.SubPath, "/") { + s.SubPath += "/" + } _, err := time.LoadLocation(s.TimeLocation) if err != nil { diff --git a/web/html/common/qrcode_modal.html b/web/html/common/qrcode_modal.html index 2db1948b..85ada3d4 100644 --- a/web/html/common/qrcode_modal.html +++ b/web/html/common/qrcode_modal.html @@ -86,8 +86,7 @@ }); }, genSubLink(subID) { - const { domain: host, port, tls: isTLS, path: base } = app.subSettings; - return buildURL({ host, port, isTLS, base, path: subID+'?name='+remark }); + return app.subSettings.subURI+subID+'?name='+subID; } }, updated() { diff --git a/web/html/xui/component/setting.html b/web/html/xui/component/setting.html index 568f03de..82c0ae75 100644 --- a/web/html/xui/component/setting.html +++ b/web/html/xui/component/setting.html @@ -13,10 +13,10 @@