mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-25 11:10:29 +08:00
可以在缓存设置中搜索缓存条件
This commit is contained in:
@@ -28,12 +28,18 @@ Vue.component("http-cache-config-box", {
|
|||||||
cacheConfig: cacheConfig,
|
cacheConfig: cacheConfig,
|
||||||
moreOptionsVisible: false,
|
moreOptionsVisible: false,
|
||||||
enablePolicyRefs: !cacheConfig.disablePolicyRefs,
|
enablePolicyRefs: !cacheConfig.disablePolicyRefs,
|
||||||
maxBytes: maxBytes
|
maxBytes: maxBytes,
|
||||||
|
|
||||||
|
searchBoxVisible: false,
|
||||||
|
searchKeyword: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
enablePolicyRefs: function (v) {
|
enablePolicyRefs: function (v) {
|
||||||
this.cacheConfig.disablePolicyRefs = !v
|
this.cacheConfig.disablePolicyRefs = !v
|
||||||
|
},
|
||||||
|
searchKeyword: function (v) {
|
||||||
|
this.$refs.cacheRefsConfigBoxRef.search(v)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -58,6 +64,18 @@ Vue.component("http-cache-config-box", {
|
|||||||
},
|
},
|
||||||
changeStale: function (stale) {
|
changeStale: function (stale) {
|
||||||
this.cacheConfig.stale = stale
|
this.cacheConfig.stale = stale
|
||||||
|
},
|
||||||
|
|
||||||
|
showSearchBox: function () {
|
||||||
|
this.searchBoxVisible = !this.searchBoxVisible
|
||||||
|
if (this.searchBoxVisible) {
|
||||||
|
let that = this
|
||||||
|
setTimeout(function () {
|
||||||
|
that.$refs.searchBox.focus()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.searchKeyword = ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `<div>
|
template: `<div>
|
||||||
@@ -147,7 +165,12 @@ Vue.component("http-cache-config-box", {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-show="isOn()" style="margin-top: 1em">
|
<div v-show="isOn()" style="margin-top: 1em">
|
||||||
<h4>缓存条件 <a href="" style="font-size: 0.8em" @click.prevent="$refs.cacheRefsConfigBoxRef.addRef(false)">[添加]</a> </h4>
|
<h4 style="position: relative">缓存条件 <a href="" style="font-size: 0.8em" @click.prevent="$refs.cacheRefsConfigBoxRef.addRef(false)">[添加]</a> <a href="" style="font-size: 0.8em" @click.prevent="showSearchBox" v-show="!searchBoxVisible">[搜索]</a>
|
||||||
|
<div class="ui input small right labeled" style="position: absolute; top: -0.6em" v-show="searchBoxVisible">
|
||||||
|
<input type="text" placeholder="搜索..." ref="searchBox" @keypress.enter.prevent="1" @keydown.esc="showSearchBox" v-model="searchKeyword" />
|
||||||
|
<a href="" class="ui label blue" @click.prevent="showSearchBox"><i class="icon remove small"></i></a>
|
||||||
|
</div>
|
||||||
|
</h4>
|
||||||
<http-cache-refs-config-box ref="cacheRefsConfigBoxRef" :v-cache-config="cacheConfig" :v-cache-refs="cacheConfig.cacheRefs" :v-web-id="vWebId" :v-max-bytes="maxBytes"></http-cache-refs-config-box>
|
<http-cache-refs-config-box ref="cacheRefsConfigBoxRef" :v-cache-config="cacheConfig" :v-cache-refs="cacheConfig.cacheRefs" :v-web-id="vWebId" :v-max-bytes="maxBytes"></http-cache-refs-config-box>
|
||||||
</div>
|
</div>
|
||||||
<div class="margin"></div>
|
<div class="margin"></div>
|
||||||
|
|||||||
@@ -25,8 +25,10 @@ Vue.component("http-cache-refs-config-box", {
|
|||||||
|
|
||||||
let id = 0
|
let id = 0
|
||||||
refs.forEach(function (ref) {
|
refs.forEach(function (ref) {
|
||||||
|
// preset variables
|
||||||
id++
|
id++
|
||||||
ref.id = id
|
ref.id = id
|
||||||
|
ref.visible = true
|
||||||
|
|
||||||
// check max size
|
// check max size
|
||||||
if (ref.maxSize != null && maxBytes != null && maxBytes.count > 0 && teaweb.compareSizeCapacity(ref.maxSize, maxBytes) > 0) {
|
if (ref.maxSize != null && maxBytes != null && maxBytes.count > 0 && teaweb.compareSizeCapacity(ref.maxSize, maxBytes) > 0) {
|
||||||
@@ -162,6 +164,41 @@ Vue.component("http-cache-refs-config-box", {
|
|||||||
})
|
})
|
||||||
.post()
|
.post()
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
search: function (keyword) {
|
||||||
|
if (typeof keyword != "string") {
|
||||||
|
keyword = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
this.refs.forEach(function (ref) {
|
||||||
|
if (keyword.length == 0) {
|
||||||
|
ref.visible = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ref.visible = false
|
||||||
|
|
||||||
|
// simple cond
|
||||||
|
if (ref.simpleCond != null && typeof ref.simpleCond.value == "string" && teaweb.match(ref.simpleCond.value, keyword)) {
|
||||||
|
ref.visible = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// composed conds
|
||||||
|
if (ref.conds == null || ref.conds.groups == null || ref.conds.groups.length == 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ref.conds.groups.forEach(function (group) {
|
||||||
|
if (group.conds != null) {
|
||||||
|
group.conds.forEach(function (cond) {
|
||||||
|
if (typeof cond.value == "string" && teaweb.match(cond.value, keyword)) {
|
||||||
|
ref.visible = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
this.$forceUpdate()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `<div>
|
template: `<div>
|
||||||
@@ -178,7 +215,7 @@ Vue.component("http-cache-refs-config-box", {
|
|||||||
<th class="three op">操作</th>
|
<th class="three op">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody v-for="(cacheRef, index) in refs" :key="cacheRef.id" :v-id="cacheRef.id">
|
<tbody v-for="(cacheRef, index) in refs" :key="cacheRef.id" :v-id="cacheRef.id" v-show="cacheRef.visible !== false">
|
||||||
<tr>
|
<tr>
|
||||||
<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 != null && cacheRef.conds.connector == 'and', disabled: !cacheRef.isOn}" :style="{'border-left':cacheRef.isReverse ? '1px #db2828 solid' : ''}">
|
<td :class="{'color-border': cacheRef.conds != null && cacheRef.conds.connector == 'and', disabled: !cacheRef.isOn}" :style="{'border-left':cacheRef.isReverse ? '1px #db2828 solid' : ''}">
|
||||||
|
|||||||
@@ -126,7 +126,7 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h4>默认缓存条件</h4>
|
<h4>默认缓存条件</h4>
|
||||||
<http-cache-refs-config-box :v-cache-refs="cachePolicy.cacheRefs" :v-cache-policy-id="cachePolicy.id"></http-cache-refs-config-box>
|
<http-cache-refs-config-box :v-cache-refs="cachePolicy.cacheRefs" :v-cache-policy-id="cachePolicy.id" :v-max-bytes="cachePolicy.maxSize"></http-cache-refs-config-box>
|
||||||
|
|
||||||
<submit-btn></submit-btn>
|
<submit-btn></submit-btn>
|
||||||
</form>
|
</form>
|
||||||
Reference in New Issue
Block a user