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,
|
||||
moreOptionsVisible: false,
|
||||
enablePolicyRefs: !cacheConfig.disablePolicyRefs,
|
||||
maxBytes: maxBytes
|
||||
maxBytes: maxBytes,
|
||||
|
||||
searchBoxVisible: false,
|
||||
searchKeyword: ""
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
enablePolicyRefs: function (v) {
|
||||
this.cacheConfig.disablePolicyRefs = !v
|
||||
},
|
||||
searchKeyword: function (v) {
|
||||
this.$refs.cacheRefsConfigBoxRef.search(v)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -58,6 +64,18 @@ Vue.component("http-cache-config-box", {
|
||||
},
|
||||
changeStale: function (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>
|
||||
@@ -147,7 +165,12 @@ Vue.component("http-cache-config-box", {
|
||||
</div>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
<div class="margin"></div>
|
||||
|
||||
@@ -25,8 +25,10 @@ Vue.component("http-cache-refs-config-box", {
|
||||
|
||||
let id = 0
|
||||
refs.forEach(function (ref) {
|
||||
// preset variables
|
||||
id++
|
||||
ref.id = id
|
||||
ref.visible = true
|
||||
|
||||
// check max size
|
||||
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()
|
||||
}
|
||||
},
|
||||
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>
|
||||
@@ -178,7 +215,7 @@ Vue.component("http-cache-refs-config-box", {
|
||||
<th class="three op">操作</th>
|
||||
</tr>
|
||||
</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>
|
||||
<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' : ''}">
|
||||
|
||||
Reference in New Issue
Block a user