mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-12 03:04:01 +08:00
将缓存默认key改为${scheme}://${host}${requestPath}${isArgs}${args}
This commit is contained in:
33
web/public/js/components/common/request-variables.js
Normal file
33
web/public/js/components/common/request-variables.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
// 将变量转换为中文
|
||||||
|
Vue.component("request-variables-describer", {
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
vars:[]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
update: function (variablesString) {
|
||||||
|
this.vars = []
|
||||||
|
let that = this
|
||||||
|
variablesString.replace(/\${.+?}/g, function (v) {
|
||||||
|
let def = that.findVar(v)
|
||||||
|
if (def == null) {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
that.vars.push(def)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
findVar: function (name) {
|
||||||
|
let def = null
|
||||||
|
window.REQUEST_VARIABLES.forEach(function (v) {
|
||||||
|
if (v.code == name) {
|
||||||
|
def = v
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return def
|
||||||
|
}
|
||||||
|
},
|
||||||
|
template: `<span>
|
||||||
|
<span v-for="(v, index) in vars"><code-label :title="v.description">{{v.code}}</code-label> - {{v.name}}<span v-if="index < vars.length-1">;</span></span>
|
||||||
|
</span>`
|
||||||
|
})
|
||||||
@@ -1,13 +1,16 @@
|
|||||||
// 单个缓存条件设置
|
// 单个缓存条件设置
|
||||||
Vue.component("http-cache-ref-box", {
|
Vue.component("http-cache-ref-box", {
|
||||||
props: ["v-cache-ref", "v-is-reverse"],
|
props: ["v-cache-ref", "v-is-reverse"],
|
||||||
|
mounted: function () {
|
||||||
|
this.$refs.variablesDescriber.update(this.ref.key)
|
||||||
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
let ref = this.vCacheRef
|
let ref = this.vCacheRef
|
||||||
if (ref == null) {
|
if (ref == null) {
|
||||||
ref = {
|
ref = {
|
||||||
isOn: true,
|
isOn: true,
|
||||||
cachePolicyId: 0,
|
cachePolicyId: 0,
|
||||||
key: "${scheme}://${host}${requestURI}",
|
key: "${scheme}://${host}${requestPath}${isArgs}${args}",
|
||||||
life: {count: 2, unit: "hour"},
|
life: {count: 2, unit: "hour"},
|
||||||
status: [200],
|
status: [200],
|
||||||
maxSize: {count: 32, unit: "mb"},
|
maxSize: {count: 32, unit: "mb"},
|
||||||
@@ -20,6 +23,10 @@ Vue.component("http-cache-ref-box", {
|
|||||||
isReverse: this.vIsReverse
|
isReverse: this.vIsReverse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ref.key == null) {
|
||||||
|
ref.key = ""
|
||||||
|
}
|
||||||
|
|
||||||
if (ref.life == null) {
|
if (ref.life == null) {
|
||||||
ref.life = {count: 2, unit: "hour"}
|
ref.life = {count: 2, unit: "hour"}
|
||||||
}
|
}
|
||||||
@@ -60,6 +67,9 @@ Vue.component("http-cache-ref-box", {
|
|||||||
result.push(statusNumber)
|
result.push(statusNumber)
|
||||||
})
|
})
|
||||||
this.ref.status = result
|
this.ref.status = result
|
||||||
|
},
|
||||||
|
changeKey: function (key) {
|
||||||
|
this.$refs.variablesDescriber.update(key)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `<tbody>
|
template: `<tbody>
|
||||||
@@ -80,8 +90,8 @@ Vue.component("http-cache-ref-box", {
|
|||||||
<tr v-show="!vIsReverse">
|
<tr v-show="!vIsReverse">
|
||||||
<td>缓存Key *</td>
|
<td>缓存Key *</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" v-model="ref.key"/>
|
<input type="text" v-model="ref.key" @input="changeKey(ref.key)"/>
|
||||||
<p class="comment">用来区分不同缓存内容的唯一Key。</p>
|
<p class="comment">用来区分不同缓存内容的唯一Key。<request-variables-describer ref="variablesDescriber"></request-variables-describer>。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-show="!vIsReverse">
|
<tr v-show="!vIsReverse">
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ Vue.component("http-cache-refs-config-box", {
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p class="comment" v-if="refs.length > 1">所有条件匹配顺序为从上到下,可以拖动左侧的<i class="icon bars"></i>排序。</p>
|
<p class="comment" v-if="refs.length > 1">所有条件匹配顺序为从上到下,可以拖动左侧的<i class="icon bars"></i>排序。服务设置的优先级比全局缓存策略设置的优先级要高。</p>
|
||||||
|
|
||||||
<button class="ui button tiny" @click.prevent="addRef(false)">+添加缓存设置</button> <a href="" @click.prevent="addRef(true)">+添加不缓存设置</a>
|
<button class="ui button tiny" @click.prevent="addRef(false)">+添加缓存设置</button> <a href="" @click.prevent="addRef(true)">+添加不缓存设置</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ Vue.component("http-header-policy-box", {
|
|||||||
responseDeletingHeaders = responsePolicy.deleteHeaders
|
responseDeletingHeaders = responsePolicy.deleteHeaders
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: type,
|
type: type,
|
||||||
typeName: (type == "request") ? "请求" : "响应",
|
typeName: (type == "request") ? "请求" : "响应",
|
||||||
@@ -74,21 +74,21 @@ Vue.component("http-header-policy-box", {
|
|||||||
addSettingHeader: function (policyId) {
|
addSettingHeader: function (policyId) {
|
||||||
teaweb.popup("/servers/server/settings/headers/createSetPopup?" + this.vParams + "&headerPolicyId=" + policyId, {
|
teaweb.popup("/servers/server/settings/headers/createSetPopup?" + this.vParams + "&headerPolicyId=" + policyId, {
|
||||||
callback: function () {
|
callback: function () {
|
||||||
window.location.reload()
|
teaweb.successRefresh("保存成功")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
addDeletingHeader: function (policyId, type) {
|
addDeletingHeader: function (policyId, type) {
|
||||||
teaweb.popup("/servers/server/settings/headers/createDeletePopup?" + this.vParams + "&headerPolicyId=" + policyId + "&type=" + type, {
|
teaweb.popup("/servers/server/settings/headers/createDeletePopup?" + this.vParams + "&headerPolicyId=" + policyId + "&type=" + type, {
|
||||||
callback: function () {
|
callback: function () {
|
||||||
window.location.reload()
|
teaweb.successRefresh("保存成功")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateSettingPopup: function (policyId, headerId) {
|
updateSettingPopup: function (policyId, headerId) {
|
||||||
teaweb.popup("/servers/server/settings/headers/updateSetPopup?" + this.vParams + "&headerPolicyId=" + policyId + "&headerId=" + headerId, {
|
teaweb.popup("/servers/server/settings/headers/updateSetPopup?" + this.vParams + "&headerPolicyId=" + policyId + "&headerId=" + headerId, {
|
||||||
callback: function () {
|
callback: function () {
|
||||||
window.location.reload()
|
teaweb.successRefresh("保存成功")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user