diff --git a/internal/web/actions/default/servers/server/settings/pages/createPopup.go b/internal/web/actions/default/servers/server/settings/pages/createPopup.go index c42a29cb..84870cf2 100644 --- a/internal/web/actions/default/servers/server/settings/pages/createPopup.go +++ b/internal/web/actions/default/servers/server/settings/pages/createPopup.go @@ -6,7 +6,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/langs/codes" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/types" ) @@ -20,7 +19,7 @@ func (this *CreatePopupAction) Init() { } func (this *CreatePopupAction) RunGet(params struct{}) { - this.Data["bodyTypes"] = shared.FindAllBodyTypes() + this.Data["bodyTypes"] = serverconfigs.FindAllHTTPPageBodyTypes() this.Show() } @@ -42,12 +41,17 @@ func (this *CreatePopupAction) RunPost(params struct { Require("请输入响应状态码") switch params.BodyType { - case shared.BodyTypeURL: + case serverconfigs.HTTPPageBodyTypeURL: params.Must. Field("url", params.URL). Require("请输入要显示的URL"). Match( `^(?i)(http|https)://`, "请输入正确的URL") - case shared.BodyTypeHTML: + case serverconfigs.HTTPPageBodyTypeRedirectURL: + params.Must. + Field("url", params.URL). + Require("请输入要跳转的URL"). + Match( `^(?i)(http|https)://`, "请输入正确的URL") + case serverconfigs.HTTPPageBodyTypeHTML: params.Must. Field("body", params.Body). Require("请输入要显示的HTML内容") diff --git a/internal/web/actions/default/servers/server/settings/pages/index.go b/internal/web/actions/default/servers/server/settings/pages/index.go index 513d879e..867d9de0 100644 --- a/internal/web/actions/default/servers/server/settings/pages/index.go +++ b/internal/web/actions/default/servers/server/settings/pages/index.go @@ -7,7 +7,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/types" "regexp" @@ -77,7 +76,11 @@ func (this *IndexAction) RunPost(params struct { } // check url - if page.BodyType == shared.BodyTypeURL && !urlReg.MatchString(page.URL) { + if page.BodyType == serverconfigs.HTTPPageBodyTypeURL && !urlReg.MatchString(page.URL) { + this.Fail("自定义页面中 '" + page.URL + "' 不是一个正确的URL,请进行修改") + return + } + if page.BodyType == serverconfigs.HTTPPageBodyTypeRedirectURL && !urlReg.MatchString(page.URL) { this.Fail("自定义页面中 '" + page.URL + "' 不是一个正确的URL,请进行修改") return } @@ -99,7 +102,7 @@ func (this *IndexAction) RunPost(params struct { return } - if shutdownConfig.BodyType == shared.BodyTypeURL { + if shutdownConfig.BodyType == serverconfigs.HTTPPageBodyTypeURL { if len(shutdownConfig.URL) > 512 { this.Fail("临时关闭页面中URL过长,不能超过512字节") return @@ -109,7 +112,17 @@ func (this *IndexAction) RunPost(params struct { this.Fail("临时关闭页面中 '" + shutdownConfig.URL + "' 不是一个正确的URL,请进行修改") return } - } else if shutdownConfig.Body == shared.BodyTypeHTML { + } else if shutdownConfig.BodyType == serverconfigs.HTTPPageBodyTypeRedirectURL { + if len(shutdownConfig.URL) > 512 { + this.Fail("临时关闭页面中URL过长,不能超过512字节") + return + } + + if shutdownConfig.IsOn /** 只有启用的时候才校验 **/ && !urlReg.MatchString(shutdownConfig.URL) { + this.Fail("临时关闭页面中 '" + shutdownConfig.URL + "' 不是一个正确的URL,请进行修改") + return + } + } else if shutdownConfig.Body == serverconfigs.HTTPPageBodyTypeHTML { if len(shutdownConfig.Body) > 32*1024 { this.Fail("临时关闭页面中HTML内容长度不能超过32K") return diff --git a/internal/web/actions/default/servers/server/settings/pages/updatePopup.go b/internal/web/actions/default/servers/server/settings/pages/updatePopup.go index 175b553d..af159a65 100644 --- a/internal/web/actions/default/servers/server/settings/pages/updatePopup.go +++ b/internal/web/actions/default/servers/server/settings/pages/updatePopup.go @@ -6,7 +6,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/langs/codes" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/types" ) @@ -22,7 +21,7 @@ func (this *UpdatePopupAction) Init() { func (this *UpdatePopupAction) RunGet(params struct { PageId int64 }) { - this.Data["bodyTypes"] = shared.FindAllBodyTypes() + this.Data["bodyTypes"] = serverconfigs.FindAllHTTPPageBodyTypes() configResp, err := this.RPC().HTTPPageRPC().FindEnabledHTTPPageConfig(this.AdminContext(), &pb.FindEnabledHTTPPageConfigRequest{HttpPageId: params.PageId}) if err != nil { @@ -62,12 +61,17 @@ func (this *UpdatePopupAction) RunPost(params struct { Require("请输入响应状态码") switch params.BodyType { - case shared.BodyTypeURL: + case serverconfigs.HTTPPageBodyTypeURL: params.Must. Field("url", params.URL). Require("请输入要显示的URL"). - Match( `^(?i)(http|https)://`, "请输入正确的URL") - case shared.BodyTypeHTML: + Match(`^(?i)(http|https)://`, "请输入正确的URL") + case serverconfigs.HTTPPageBodyTypeRedirectURL: + params.Must. + Field("url", params.URL). + Require("请输入要跳转的URL"). + Match(`^(?i)(http|https)://`, "请输入正确的URL") + case serverconfigs.HTTPPageBodyTypeHTML: params.Must. Field("body", params.Body). Require("请输入要显示的HTML内容") diff --git a/web/public/js/components/server/http-pages-and-shutdown-box.js b/web/public/js/components/server/http-pages-and-shutdown-box.js index 858e63cb..5e1bfc9b 100644 --- a/web/public/js/components/server/http-pages-and-shutdown-box.js +++ b/web/public/js/components/server/http-pages-and-shutdown-box.js @@ -132,7 +132,28 @@ Vue.component("http-pages-and-shutdown-box", { {{page.status[0]}} {{page.status}} -
将从此URL中读取内容。
将会跳转到此URL。
+将从此URL中读取内容。
-[使用模板]。填写页面的HTML内容,支持请求变量。
将从此URL中读取内容。
+将会跳转到此URL。
+将从此URL中读取内容。
-[使用模板]。填写页面的HTML内容,支持请求变量。
将从此URL中读取内容。
+将会跳转到此URL。
+