diff --git a/internal/web/actions/default/servers/groups/group/settings/pages/index.go b/internal/web/actions/default/servers/groups/group/settings/pages/index.go index edad89a5..b2307f92 100644 --- a/internal/web/actions/default/servers/groups/group/settings/pages/index.go +++ b/internal/web/actions/default/servers/groups/group/settings/pages/index.go @@ -1,6 +1,7 @@ package pages -import ( "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" +import ( + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/groups/group/servergrouputils" "github.com/TeaOSLab/EdgeCommon/pkg/langs/codes" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao" @@ -33,6 +34,7 @@ func (this *IndexAction) RunGet(params struct { } this.Data["webId"] = webConfig.Id + this.Data["enableGlobalPages"] = webConfig.EnableGlobalPages this.Data["pages"] = webConfig.Pages this.Data["shutdownConfig"] = webConfig.Shutdown @@ -40,17 +42,27 @@ func (this *IndexAction) RunGet(params struct { } func (this *IndexAction) RunPost(params struct { - WebId int64 - PagesJSON string - ShutdownJSON string - Must *actions.Must + WebId int64 + EnableGlobalPages bool + PagesJSON string + ShutdownJSON string + Must *actions.Must }) { // 日志 defer this.CreateLogInfo(codes.ServerPage_LogUpdatePages, params.WebId) // TODO 检查配置 - _, err := this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{ + _, err := this.RPC().HTTPWebRPC().UpdateHTTPWebGlobalPagesEnabled(this.AdminContext(), &pb.UpdateHTTPWebGlobalPagesEnabledRequest{ + HttpWebId: params.WebId, + IsEnabled: params.EnableGlobalPages, + }) + if err != nil { + this.ErrorPage(err) + return + } + + _, err = this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{ HttpWebId: params.WebId, PagesJSON: []byte(params.PagesJSON), }) diff --git a/internal/web/actions/default/servers/server/settings/locations/pages/index.go b/internal/web/actions/default/servers/server/settings/locations/pages/index.go index 33700a37..635bf33f 100644 --- a/internal/web/actions/default/servers/server/settings/locations/pages/index.go +++ b/internal/web/actions/default/servers/server/settings/locations/pages/index.go @@ -25,6 +25,7 @@ func (this *IndexAction) RunGet(params struct { } this.Data["webId"] = webConfig.Id + this.Data["enableGlobalPages"] = webConfig.EnableGlobalPages this.Data["pages"] = webConfig.Pages this.Data["shutdownConfig"] = webConfig.Shutdown @@ -32,16 +33,26 @@ func (this *IndexAction) RunGet(params struct { } func (this *IndexAction) RunPost(params struct { - WebId int64 - PagesJSON string - ShutdownJSON string - Must *actions.Must + WebId int64 + EnableGlobalPages bool + PagesJSON string + ShutdownJSON string + Must *actions.Must }) { defer this.CreateLogInfo(codes.ServerPage_LogUpdatePages, params.WebId) // TODO 检查配置 - _, err := this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{ + _, err := this.RPC().HTTPWebRPC().UpdateHTTPWebGlobalPagesEnabled(this.AdminContext(), &pb.UpdateHTTPWebGlobalPagesEnabledRequest{ + HttpWebId: params.WebId, + IsEnabled: params.EnableGlobalPages, + }) + if err != nil { + this.ErrorPage(err) + return + } + + _, err = this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{ HttpWebId: params.WebId, PagesJSON: []byte(params.PagesJSON), }) 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 f756c079..c7e25f40 100644 --- a/internal/web/actions/default/servers/server/settings/pages/index.go +++ b/internal/web/actions/default/servers/server/settings/pages/index.go @@ -47,6 +47,7 @@ func (this *IndexAction) RunGet(params struct { } this.Data["webId"] = webConfig.Id + this.Data["enableGlobalPages"] = webConfig.EnableGlobalPages this.Data["pages"] = webConfig.Pages this.Data["shutdownConfig"] = webConfig.Shutdown @@ -54,10 +55,11 @@ func (this *IndexAction) RunGet(params struct { } func (this *IndexAction) RunPost(params struct { - WebId int64 - PagesJSON []byte - ShutdownJSON []byte - Must *actions.Must + WebId int64 + PagesJSON []byte + ShutdownJSON []byte + EnableGlobalPages bool + Must *actions.Must }) { // 日志 defer this.CreateLogInfo(codes.ServerPage_LogUpdatePages, params.WebId) @@ -135,7 +137,16 @@ func (this *IndexAction) RunPost(params struct { } } - _, err := this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{ + _, err := this.RPC().HTTPWebRPC().UpdateHTTPWebGlobalPagesEnabled(this.AdminContext(), &pb.UpdateHTTPWebGlobalPagesEnabledRequest{ + HttpWebId: params.WebId, + IsEnabled: params.EnableGlobalPages, + }) + if err != nil { + this.ErrorPage(err) + return + } + + _, err = this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{ HttpWebId: params.WebId, PagesJSON: params.PagesJSON, }) diff --git a/web/public/js/components.js b/web/public/js/components.js index 65197035..578f1347 100644 --- a/web/public/js/components.js +++ b/web/public/js/components.js @@ -3808,7 +3808,7 @@ example2.com
[选择已有策略]     [创建新策略]
-`}),Vue.component("http-pages-and-shutdown-box",{props:["v-pages","v-shutdown-config","v-is-location"],data:function(){let e=[],t=(null!=this.vPages&&(e=this.vPages),{isPrior:!1,isOn:!1,bodyType:"html",url:"",body:"",status:0}),i=(null!=this.vShutdownConfig&&(null==this.vShutdownConfig.body&&(this.vShutdownConfig.body=""),null==this.vShutdownConfig.bodyType&&(this.vShutdownConfig.bodyType="html"),t=this.vShutdownConfig),"");return 0 +`}),Vue.component("http-pages-and-shutdown-box",{props:["v-enable-global-pages","v-pages","v-shutdown-config","v-is-location"],data:function(){let e=[],t=(null!=this.vPages&&(e=this.vPages),{isPrior:!1,isOn:!1,bodyType:"html",url:"",body:"",status:0}),i=(null!=this.vShutdownConfig&&(null==this.vShutdownConfig.body&&(this.vShutdownConfig.body=""),null==this.vShutdownConfig.bodyType&&(this.vShutdownConfig.bodyType="html"),t=this.vShutdownConfig),"");return 0 升级中 @@ -3829,6 +3829,7 @@ example2.com `},notifyChange:function(){let e=this.$el.parentNode;for(;;){if(null==e)break;if("FORM"==e.tagName)break;e=e.parentNode}null!=e&&setTimeout(function(){Tea.runActionOn(e)},100)}},template:`
+

自定义页面

根据响应状态码返回一些自定义页面,比如404,500等错误页面。

@@ -3958,7 +3959,19 @@ example2.com
+ +

其他设置

+ + + + + +
启用系统自定义页面 + +

选中后,表示如果当前网站没有自定义页面,则尝试使用系统对应的自定义页面。

+
+ `}),Vue.component("http-firewall-page-options",{props:["v-page-options"],data:function(){return{pageOptions:this.vPageOptions,status:this.vPageOptions.status,body:this.vPageOptions.body,defaultPageBody:` diff --git a/web/public/js/components.src.js b/web/public/js/components.src.js index fc1845c0..b92838fc 100755 --- a/web/public/js/components.src.js +++ b/web/public/js/components.src.js @@ -10603,7 +10603,7 @@ Vue.component("http-cache-policy-selector", { }) Vue.component("http-pages-and-shutdown-box", { - props: ["v-pages", "v-shutdown-config", "v-is-location"], + props: ["v-enable-global-pages", "v-pages", "v-shutdown-config", "v-is-location"], data: function () { let pages = [] if (this.vPages != null) { @@ -10635,7 +10635,8 @@ Vue.component("http-pages-and-shutdown-box", { return { pages: pages, shutdownConfig: shutdownConfig, - shutdownStatus: shutdownStatus + shutdownStatus: shutdownStatus, + enableGlobalPages: this.vEnableGlobalPages } }, watch: { @@ -10718,6 +10719,7 @@ Vue.component("http-pages-and-shutdown-box", { template: `
+

自定义页面

根据响应状态码返回一些自定义页面,比如404,500等错误页面。

@@ -10847,7 +10849,19 @@ Vue.component("http-pages-and-shutdown-box", {
+ +

其他设置

+ + + + + +
启用系统自定义页面 + +

选中后,表示如果当前网站没有自定义页面,则尝试使用系统对应的自定义页面。

+
+ ` }) 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 92856271..2ff4a0fb 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 @@ -1,5 +1,5 @@ Vue.component("http-pages-and-shutdown-box", { - props: ["v-pages", "v-shutdown-config", "v-is-location"], + props: ["v-enable-global-pages", "v-pages", "v-shutdown-config", "v-is-location"], data: function () { let pages = [] if (this.vPages != null) { @@ -31,7 +31,8 @@ Vue.component("http-pages-and-shutdown-box", { return { pages: pages, shutdownConfig: shutdownConfig, - shutdownStatus: shutdownStatus + shutdownStatus: shutdownStatus, + enableGlobalPages: this.vEnableGlobalPages } }, watch: { @@ -114,6 +115,7 @@ Vue.component("http-pages-and-shutdown-box", { template: `
+

自定义页面

根据响应状态码返回一些自定义页面,比如404,500等错误页面。

@@ -243,6 +245,18 @@ Vue.component("http-pages-and-shutdown-box", {
+ +

其他设置

+ + + + + +
启用系统自定义页面 + +

选中后,表示如果当前网站没有自定义页面,则尝试使用系统对应的自定义页面。

+
+ ` }) \ No newline at end of file diff --git a/web/views/@default/servers/groups/group/settings/pages/index.html b/web/views/@default/servers/groups/group/settings/pages/index.html index b7aa814e..ccc28b12 100644 --- a/web/views/@default/servers/groups/group/settings/pages/index.html +++ b/web/views/@default/servers/groups/group/settings/pages/index.html @@ -5,7 +5,7 @@
- +
\ No newline at end of file diff --git a/web/views/@default/servers/server/settings/locations/pages/index.html b/web/views/@default/servers/server/settings/locations/pages/index.html index 1d68c03f..79a6995d 100644 --- a/web/views/@default/servers/server/settings/locations/pages/index.html +++ b/web/views/@default/servers/server/settings/locations/pages/index.html @@ -9,7 +9,7 @@
- +
diff --git a/web/views/@default/servers/server/settings/pages/index.html b/web/views/@default/servers/server/settings/pages/index.html index 5e392477..27d9ee67 100644 --- a/web/views/@default/servers/server/settings/pages/index.html +++ b/web/views/@default/servers/server/settings/pages/index.html @@ -11,7 +11,7 @@
- +