缓存条件增加最小内容尺寸配置

This commit is contained in:
GoEdgeLab
2021-09-26 15:01:52 +08:00
parent 2dd4687c7f
commit dd022007ee
4 changed files with 32 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ Vue.component("http-cache-ref-box", {
life: {count: 2, unit: "hour"}, life: {count: 2, unit: "hour"},
status: [200], status: [200],
maxSize: {count: 32, unit: "mb"}, maxSize: {count: 32, unit: "mb"},
minSize: {count: 0, unit: "kb"},
skipCacheControlValues: ["private", "no-cache", "no-store"], skipCacheControlValues: ["private", "no-cache", "no-store"],
skipSetCookie: true, skipSetCookie: true,
enableRequestCachePragma: false, enableRequestCachePragma: false,
@@ -25,6 +26,9 @@ Vue.component("http-cache-ref-box", {
if (ref.maxSize == null) { if (ref.maxSize == null) {
ref.maxSize = {count: 32, unit: "mb"} ref.maxSize = {count: 32, unit: "mb"}
} }
if (ref.minSize == null) {
ref.minSize = {count: 0, unit: "kb"}
}
return { return {
ref: ref, ref: ref,
moreOptionsVisible: false moreOptionsVisible: false
@@ -40,6 +44,9 @@ Vue.component("http-cache-ref-box", {
changeMaxSize: function (v) { changeMaxSize: function (v) {
this.ref.maxSize = v this.ref.maxSize = v
}, },
changeMinSize: function (v) {
this.ref.minSize = v
},
changeConds: function (v) { changeConds: function (v) {
this.ref.conds = v this.ref.conds = v
}, },
@@ -81,9 +88,17 @@ Vue.component("http-cache-ref-box", {
<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"> <tr v-show="moreOptionsVisible && !vIsReverse">
<td>可缓存的最大文件</td> <td>可缓存的最大内容尺寸</td>
<td> <td>
<size-capacity-box :v-value="ref.maxSize" @change="changeMaxSize"></size-capacity-box> <size-capacity-box :v-value="ref.maxSize" @change="changeMaxSize"></size-capacity-box>
<p class="comment">内容尺寸如果高于此值则不缓存。</p>
</td>
</tr>
<tr v-show="moreOptionsVisible && !vIsReverse">
<td>可缓存的最小内容尺寸</td>
<td>
<size-capacity-box :v-value="ref.minSize" @change="changeMinSize"></size-capacity-box>
<p class="comment">内容尺寸如果低于此值则不缓存。</p>
</td> </td>
</tr> </tr>
<tr v-show="moreOptionsVisible && !vIsReverse"> <tr v-show="moreOptionsVisible && !vIsReverse">

View File

@@ -37,13 +37,19 @@ Vue.component("http-cache-refs-box", {
<table class="ui table selectable celled"> <table class="ui table selectable celled">
<thead> <thead>
<tr> <tr>
<th>条件</th> <th>缓存条件</th>
<th class="two">分组关系</th> <th class="two wide">分组关系</th>
<th class="width10">缓存时间</th> <th class="width10">缓存时间</th>
</tr> </tr>
<tr v-for="(cacheRef, index) in refs"> <tr v-for="(cacheRef, index) in refs">
<td :class="{'color-border': cacheRef.conds.connector == 'and'}" :style="{'border-left':cacheRef.isReverse ? '1px #db2828 solid' : ''}"> <td :class="{'color-border': cacheRef.conds.connector == 'and'}" :style="{'border-left':cacheRef.isReverse ? '1px #db2828 solid' : ''}">
<http-request-conds-view :v-conds="cacheRef.conds"></http-request-conds-view> <http-request-conds-view :v-conds="cacheRef.conds"></http-request-conds-view>
<grey-label v-if="cacheRef.minSize != null && cacheRef.minSize.count > 0">
{{cacheRef.minSize.count}}{{cacheRef.minSize.unit}}
<span v-if="cacheRef.maxSize != null && cacheRef.maxSize.count > 0">- {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}}</span>
</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.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>
<span v-if="cacheRef.conds.connector == 'and'">和</span> <span v-if="cacheRef.conds.connector == 'and'">和</span>

View File

@@ -156,7 +156,7 @@ Vue.component("http-cache-refs-config-box", {
<thead> <thead>
<tr> <tr>
<th style="width:1em"></th> <th style="width:1em"></th>
<th>条件</th> <th>缓存条件</th>
<th class="two wide">分组关系</th> <th class="two wide">分组关系</th>
<th class="width10">缓存时间</th> <th class="width10">缓存时间</th>
<th class="two op">操作</th> <th class="two op">操作</th>
@@ -167,6 +167,12 @@ Vue.component("http-cache-refs-config-box", {
<td style="text-align: center;"><i class="icon bars handle grey"></i> </td> <td style="text-align: center;"><i class="icon bars handle grey"></i> </td>
<td :class="{'color-border': cacheRef.conds.connector == 'and'}" :style="{'border-left':cacheRef.isReverse ? '1px #db2828 solid' : ''}"> <td :class="{'color-border': cacheRef.conds.connector == 'and'}" :style="{'border-left':cacheRef.isReverse ? '1px #db2828 solid' : ''}">
<http-request-conds-view :v-conds="cacheRef.conds" ref="cacheRef"></http-request-conds-view> <http-request-conds-view :v-conds="cacheRef.conds" ref="cacheRef"></http-request-conds-view>
<grey-label v-if="cacheRef.minSize != null && cacheRef.minSize.count > 0">
{{cacheRef.minSize.count}}{{cacheRef.minSize.unit}}
<span v-if="cacheRef.maxSize != null && cacheRef.maxSize.count > 0">- {{cacheRef.maxSize.count}}{{cacheRef.maxSize.unit}}</span>
</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.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>
<span v-if="cacheRef.conds.connector == 'and'">和</span> <span v-if="cacheRef.conds.connector == 'and'">和</span>

View File

@@ -54,7 +54,7 @@ Vue.component("http-request-conds-view", {
<div v-if="conds.groups.length > 0"> <div v-if="conds.groups.length > 0">
<div v-for="(group, groupIndex) in conds.groups"> <div v-for="(group, groupIndex) in conds.groups">
<var v-for="(cond, index) in group.conds" style="font-style: normal;display: inline-block; margin-bottom:0.5em"> <var v-for="(cond, index) in group.conds" style="font-style: normal;display: inline-block; margin-bottom:0.5em">
<span class="ui label tiny"> <span class="ui label small basic" style="line-height: 1.5">
<var v-if="cond.type.length == 0 || cond.type == 'params'" style="font-style: normal">{{cond.param}} <var>{{cond.operator}}</var></var> <var v-if="cond.type.length == 0 || cond.type == 'params'" style="font-style: normal">{{cond.param}} <var>{{cond.operator}}</var></var>
<var v-if="cond.type.length > 0 && cond.type != 'params'" style="font-style: normal">{{cond.typeName}}: </var> <var v-if="cond.type.length > 0 && cond.type != 'params'" style="font-style: normal">{{cond.typeName}}: </var>
{{cond.value}} {{cond.value}}