mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-06 14:50:25 +08:00
添加、修改、删除HTTP Header时增加通用Header提示
This commit is contained in:
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>`
|
||||
})
|
||||
Reference in New Issue
Block a user