服务增加是否合并URL中的多余分隔符选项

This commit is contained in:
GoEdgeLab
2021-11-24 14:49:42 +08:00
parent e02d9f7c87
commit 88a69ad0c9
7 changed files with 142 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package common
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("common")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
this.Data["hasGroupConfig"] = false
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), params.ServerId)
if err != nil {
this.ErrorPage(err)
return
}
this.Data["webId"] = webConfig.Id
this.Data["commonConfig"] = maps.Map{
"mergeSlashes": webConfig.MergeSlashes,
}
this.Show()
}
func (this *IndexAction) RunPost(params struct {
WebId int64
MergeSlashes bool
Must *actions.Must
CSRF *actionutils.CSRF
}) {
defer this.CreateLogInfo("修改服务Web %d 设置的其他设置", params.WebId)
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebCommon(this.AdminContext(), &pb.UpdateHTTPWebCommonRequest{
HttpWebId: params.WebId,
MergeSlashes: params.MergeSlashes,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -0,0 +1,19 @@
package common
import (
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeServer)).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/common").
GetPost("", new(IndexAction)).
EndAll()
})
}

View File

@@ -357,6 +357,19 @@ func (this *ServerHelper) createSettingsMenu(secondMenuItem string, serverIdStri
"isOn": serverConfig.TrafficLimit != nil && serverConfig.TrafficLimit.IsOn,
})
}
menuItems = append(menuItems, maps.Map{
"name": "-",
"url": "",
"isActive": false,
})
menuItems = append(menuItems, maps.Map{
"name": "其他设置",
"url": "/servers/server/settings/common?serverId=" + serverIdString,
"isActive": secondMenuItem == "common",
"isOn": serverConfig.Web != nil && serverConfig.Web.MergeSlashes,
})
} else if serverConfig.IsTCPFamily() {
menuItems = append(menuItems, maps.Map{
"name": "TCP",

View File

@@ -57,6 +57,7 @@ import (
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/accessLog"
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/cache"
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/charset"
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/common"
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/compression"
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/conds"
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/dns"

View File

@@ -0,0 +1,30 @@
// 通用设置
Vue.component("http-common-config-box", {
props: ["v-common-config"],
data: function () {
let config = this.vCommonConfig
if (config == null) {
config = {
mergeSlashes: false
}
}
return {
config: config
}
},
template: `<div>
<table class="ui table definition selectable">
<tr>
<td class="title">合并重复的路径分隔符</td>
<td>
<div class="ui checkbox">
<input type="checkbox" name="mergeSlashes" value="1" v-model="config.mergeSlashes"/>
<label></label>
</div>
<p class="comment">合并URL中重复的路径分隔符为一个比如<code-label>//hello/world</code-label>中的<code-label>//</code-label>。</p>
</td>
</tr>
</table>
<div class="margin"></div>
</div>`
})

View File

@@ -0,0 +1,15 @@
{$layout}
{$template "/left_menu"}
<div class="right-box">
<div :class="{'opacity-mask': hasGroupConfig}">
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="webId" :value="webId"/>
<http-common-config-box :v-common-config="commonConfig"></http-common-config-box>
<submit-btn></submit-btn>
</form>
</div>
</div>

View File

@@ -0,0 +1,3 @@
Tea.context(function () {
this.success = NotifyReloadSuccess("保存成功")
})