mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
自定义页面增加“跳转URL”功能
This commit is contained in:
@@ -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内容")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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内容")
|
||||
|
||||
Reference in New Issue
Block a user