缓存支持请求方法设置

This commit is contained in:
GoEdgeLab
2021-12-07 10:45:49 +08:00
parent 590292a6df
commit ccbe45e629
3 changed files with 19 additions and 1 deletions

View File

@@ -20,12 +20,16 @@ Vue.component("http-cache-ref-box", {
enableRequestCachePragma: false, enableRequestCachePragma: false,
conds: null, conds: null,
allowChunkedEncoding: true, allowChunkedEncoding: true,
isReverse: this.vIsReverse isReverse: this.vIsReverse,
methods: []
} }
} }
if (ref.key == null) { if (ref.key == null) {
ref.key = "" ref.key = ""
} }
if (ref.methods == null) {
ref.methods = []
}
if (ref.life == null) { if (ref.life == null) {
ref.life = {count: 2, unit: "hour"} ref.life = {count: 2, unit: "hour"}
@@ -68,6 +72,11 @@ Vue.component("http-cache-ref-box", {
}) })
this.ref.status = result this.ref.status = result
}, },
changeMethods: function (methods) {
this.ref.methods = methods.map(function (v) {
return v.toUpperCase()
})
},
changeKey: function (key) { changeKey: function (key) {
this.$refs.variablesDescriber.update(key) this.$refs.variablesDescriber.update(key)
} }
@@ -97,6 +106,13 @@ Vue.component("http-cache-ref-box", {
<tr v-show="!vIsReverse"> <tr v-show="!vIsReverse">
<td colspan="2"><more-options-indicator @change="changeOptionsVisible"></more-options-indicator></td> <td colspan="2"><more-options-indicator @change="changeOptionsVisible"></more-options-indicator></td>
</tr> </tr>
<tr v-show="moreOptionsVisible && !vIsReverse">
<td>请求方法</td>
<td>
<values-box size="5" maxlength="10" :values="ref.methods" @change="changeMethods"></values-box>
<p class="comment">允许请求的缓存方法,如果没有设置,则默认为<code-label>GET</code-label>、<code-label>HEAD</code-label>。</p>
</td>
</tr>
<tr v-show="moreOptionsVisible && !vIsReverse"> <tr v-show="moreOptionsVisible && !vIsReverse">
<td>可缓存的最大内容尺寸</td> <td>可缓存的最大内容尺寸</td>
<td> <td>

View File

@@ -49,6 +49,7 @@ Vue.component("http-cache-refs-box", {
<span v-if="cacheRef.maxSize != null && cacheRef.maxSize.count > 0">- {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}}</span> <span v-if="cacheRef.maxSize != null && cacheRef.maxSize.count > 0">- {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}}</span>
</grey-label> </grey-label>
<grey-label v-else-if="cacheRef.maxSize != null && cacheRef.maxSize.count > 0">0 - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}}</grey-label> <grey-label v-else-if="cacheRef.maxSize != null && cacheRef.maxSize.count > 0">0 - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}}</grey-label>
<grey-label v-if="cacheRef.methods != null && cacheRef.methods.length > 0">{{cacheRef.methods.join(", ")}}</grey-label>
<grey-label v-if="cacheRef.status != null && cacheRef.status.length > 0 && (cacheRef.status.length > 1 || cacheRef.status[0] != 200)">状态码:{{cacheRef.status.map(function(v) {return v.toString()}).join(", ")}}</grey-label> <grey-label v-if="cacheRef.status != null && cacheRef.status.length > 0 && (cacheRef.status.length > 1 || cacheRef.status[0] != 200)">状态码:{{cacheRef.status.map(function(v) {return v.toString()}).join(", ")}}</grey-label>
</td> </td>
<td> <td>

View File

@@ -172,6 +172,7 @@ Vue.component("http-cache-refs-config-box", {
<span v-if="cacheRef.maxSize != null && cacheRef.maxSize.count > 0">- {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}}</span> <span v-if="cacheRef.maxSize != null && cacheRef.maxSize.count > 0">- {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}}</span>
</grey-label> </grey-label>
<grey-label v-else-if="cacheRef.maxSize != null && cacheRef.maxSize.count > 0">0 - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}}</grey-label> <grey-label v-else-if="cacheRef.maxSize != null && cacheRef.maxSize.count > 0">0 - {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}}</grey-label>
<grey-label v-if="cacheRef.methods != null && cacheRef.methods.length > 0">{{cacheRef.methods.join(", ")}}</grey-label>
<grey-label v-if="cacheRef.status != null && cacheRef.status.length > 0 && (cacheRef.status.length > 1 || cacheRef.status[0] != 200)">状态码:{{cacheRef.status.map(function(v) {return v.toString()}).join(", ")}}</grey-label> <grey-label v-if="cacheRef.status != null && cacheRef.status.length > 0 && (cacheRef.status.length > 1 || cacheRef.status[0] != 200)">状态码:{{cacheRef.status.map(function(v) {return v.toString()}).join(", ")}}</grey-label>
</td> </td>
<td> <td>