mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-10 09:20:25 +08:00
添加、修改、删除HTTP Header时增加通用Header提示
This commit is contained in:
26
internal/web/actions/default/servers/headers/options.go
Normal file
26
internal/web/actions/default/servers/headers/options.go
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||||
|
|
||||||
|
package headers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OptionsAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *OptionsAction) RunPost(params struct {
|
||||||
|
Type string
|
||||||
|
}) {
|
||||||
|
if params.Type == "request" {
|
||||||
|
this.Data["headers"] = serverconfigs.AllHTTPCommonRequestHeaders
|
||||||
|
} else if params.Type == "response" {
|
||||||
|
this.Data["headers"] = serverconfigs.AllHTTPCommonResponseHeaders
|
||||||
|
} else {
|
||||||
|
this.Data["headers"] = []string{}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Success()
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package servers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/headers"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/users"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/users"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||||
"github.com/iwind/TeaGo"
|
"github.com/iwind/TeaGo"
|
||||||
@@ -26,10 +27,13 @@ func init() {
|
|||||||
Get("/serverNamesPopup", new(ServerNamesPopupAction)).
|
Get("/serverNamesPopup", new(ServerNamesPopupAction)).
|
||||||
Post("/status", new(StatusAction)).
|
Post("/status", new(StatusAction)).
|
||||||
|
|
||||||
//
|
// user
|
||||||
Post("/users/options", new(users.OptionsAction)).
|
Post("/users/options", new(users.OptionsAction)).
|
||||||
Post("/users/plans", new(users.PlansAction)).
|
Post("/users/plans", new(users.PlansAction)).
|
||||||
|
|
||||||
|
// header
|
||||||
|
Post("/headers/options", new(headers.OptionsAction)).
|
||||||
|
|
||||||
//
|
//
|
||||||
EndAll()
|
EndAll()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -19,8 +19,10 @@ func (this *CreateDeletePopupAction) Init() {
|
|||||||
|
|
||||||
func (this *CreateDeletePopupAction) RunGet(params struct {
|
func (this *CreateDeletePopupAction) RunGet(params struct {
|
||||||
HeaderPolicyId int64
|
HeaderPolicyId int64
|
||||||
|
Type string
|
||||||
}) {
|
}) {
|
||||||
this.Data["headerPolicyId"] = params.HeaderPolicyId
|
this.Data["headerPolicyId"] = params.HeaderPolicyId
|
||||||
|
this.Data["type"] = params.Type
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 删除Header
|
// DeleteAction 删除Header
|
||||||
type DeleteAction struct {
|
type DeleteAction struct {
|
||||||
actionutils.ParentAction
|
actionutils.ParentAction
|
||||||
}
|
}
|
||||||
|
|||||||
44
web/public/js/components/server/http-header-assitant.js
Normal file
44
web/public/js/components/server/http-header-assitant.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
Vue.component("http-header-assistant", {
|
||||||
|
props: ["v-type", "v-value"],
|
||||||
|
mounted: function () {
|
||||||
|
let that = this
|
||||||
|
Tea.action("/servers/headers/options?type=" + this.vType)
|
||||||
|
.post()
|
||||||
|
.success(function (resp) {
|
||||||
|
that.allHeaders = resp.data.headers
|
||||||
|
})
|
||||||
|
},
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
allHeaders: [],
|
||||||
|
matchedHeaders: [],
|
||||||
|
|
||||||
|
selectedHeaderName: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
vValue: function (v) {
|
||||||
|
if (v != this.selectedHeaderName) {
|
||||||
|
this.selectedHeaderName = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v.length == 0) {
|
||||||
|
this.matchedHeaders = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.matchedHeaders = this.allHeaders.filter(function (header) {
|
||||||
|
return teaweb.match(header, v)
|
||||||
|
}).slice(0, 5)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
select: function (header) {
|
||||||
|
this.$emit("select", header)
|
||||||
|
this.selectedHeaderName = header
|
||||||
|
}
|
||||||
|
},
|
||||||
|
template: `<span v-if="selectedHeaderName.length == 0">
|
||||||
|
<a href="" v-for="header in matchedHeaders" class="ui label basic tiny blue" style="font-weight: normal" @click.prevent="select(header)">{{header}}</a>
|
||||||
|
<span v-if="matchedHeaders.length > 0"> </span>
|
||||||
|
</span>`
|
||||||
|
})
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="title">名称<em>(Name)</em></td>
|
<td class="title">名称<em>(Name)</em></td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="name" maxlength="100" ref="focus"/>
|
<input type="text" name="name" maxlength="100" ref="focus" v-model="headerName"/>
|
||||||
<p class="comment">请注意名称的大小写,如无特殊需求,Header名称的格式通常为<code-label>Xxx</code-label>或者<code-label>Xxx-Yyy</code-label>。</p>
|
<p class="comment"><http-header-assistant :v-type="type" :v-value="headerName" @select="selectHeader"></http-header-assistant>请注意名称的大小写,如无特殊需求,Header名称的格式通常为<code-label>Xxx</code-label>或者<code-label>Xxx-Yyy</code-label>。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
Tea.context(function () {
|
||||||
|
this.headerName = ""
|
||||||
|
|
||||||
|
this.selectHeader = function (headerName) {
|
||||||
|
this.headerName = headerName
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="title">名称<em>(Name)</em> *</td>
|
<td class="title">名称<em>(Name)</em> *</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="name" value="" maxlength="200" placeholder="类似于Server、Content-Type之类" ref="focus"/>
|
<input type="text" name="name" value="" maxlength="200" placeholder="类似于Server、Content-Type之类" ref="focus" v-model="headerName" autocomplete="off"/>
|
||||||
<p class="comment">请注意名称的大小写,如无特殊需求,Header名称的格式通常为<code-label>Xxx</code-label>或者<code-label>Xxx-Yyy</code-label>。</p>
|
<p class="comment"><http-header-assistant :v-type="type" :v-value="headerName" @select="selectHeader"></http-header-assistant>请注意名称的大小写,如无特殊需求,Header名称的格式通常为<code-label>Xxx</code-label>或者<code-label>Xxx-Yyy</code-label>。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
Tea.context(function () {
|
Tea.context(function () {
|
||||||
this.shouldReplace = false
|
this.shouldReplace = false
|
||||||
|
this.headerName = ""
|
||||||
|
|
||||||
|
this.selectHeader = function (headerName) {
|
||||||
|
this.headerName = headerName
|
||||||
|
}
|
||||||
})
|
})
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<td class="title">名称<em>(Name)</em> *</td>
|
<td class="title">名称<em>(Name)</em> *</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="name" value="" v-model="headerConfig.name" maxlength="200" placeholder="类似于Server、Content-Type之类" ref="focus"/>
|
<input type="text" name="name" value="" v-model="headerConfig.name" maxlength="200" placeholder="类似于Server、Content-Type之类" ref="focus"/>
|
||||||
<p class="comment">请注意名称的大小写,如无特殊需求,Header名称的格式通常为<code-label>Xxx</code-label>或者<code-label>Xxx-Yyy</code-label>。</p>
|
<p class="comment"><http-header-assistant :v-type="type" :v-value="headerConfig.name" @select="selectHeader"></http-header-assistant>请注意名称的大小写,如无特殊需求,Header名称的格式通常为<code-label>Xxx</code-label>或者<code-label>Xxx-Yyy</code-label>。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -4,4 +4,8 @@ Tea.context(function () {
|
|||||||
if (this.headerConfig.status != null && this.headerConfig.status.codes != null) {
|
if (this.headerConfig.status != null && this.headerConfig.status.codes != null) {
|
||||||
this.statusList = this.headerConfig.status.codes
|
this.statusList = this.headerConfig.status.codes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.selectHeader = function (headerName) {
|
||||||
|
this.headerConfig.name = headerName
|
||||||
|
}
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user