mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-06 23:00:25 +08:00
优化代码
This commit is contained in:
@@ -17,69 +17,6 @@ Vue.component("http-cache-config-box", {
|
|||||||
methods: {
|
methods: {
|
||||||
isOn: function () {
|
isOn: function () {
|
||||||
return (!this.vIsLocation || this.cacheConfig.isPrior) && this.cacheConfig.isOn
|
return (!this.vIsLocation || this.cacheConfig.isPrior) && this.cacheConfig.isOn
|
||||||
},
|
|
||||||
addRef: function () {
|
|
||||||
window.UPDATING_CACHE_REF = null
|
|
||||||
|
|
||||||
let width = window.innerWidth
|
|
||||||
if (width > 1024) {
|
|
||||||
width = 1024
|
|
||||||
}
|
|
||||||
let height = window.innerHeight
|
|
||||||
if (height > 500) {
|
|
||||||
height = 500
|
|
||||||
}
|
|
||||||
let that = this
|
|
||||||
teaweb.popup("/servers/server/settings/cache/createPopup", {
|
|
||||||
width: width + "px",
|
|
||||||
height: height + "px",
|
|
||||||
callback: function (resp) {
|
|
||||||
that.cacheConfig.cacheRefs.push(resp.data.cacheRef)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
updateRef: function (index, cacheRef) {
|
|
||||||
window.UPDATING_CACHE_REF = cacheRef
|
|
||||||
|
|
||||||
let width = window.innerWidth
|
|
||||||
if (width > 1024) {
|
|
||||||
width = 1024
|
|
||||||
}
|
|
||||||
let height = window.innerHeight
|
|
||||||
if (height > 500) {
|
|
||||||
height = 500
|
|
||||||
}
|
|
||||||
let that = this
|
|
||||||
teaweb.popup("/servers/server/settings/cache/createPopup", {
|
|
||||||
width: width + "px",
|
|
||||||
height: height + "px",
|
|
||||||
callback: function (resp) {
|
|
||||||
Vue.set(that.cacheConfig.cacheRefs, index, resp.data.cacheRef)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
removeRef: function (index) {
|
|
||||||
let that = this
|
|
||||||
teaweb.confirm("确定要删除此缓存设置吗?", function () {
|
|
||||||
that.cacheConfig.cacheRefs.$remove(index)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
timeUnitName: function (unit) {
|
|
||||||
switch (unit) {
|
|
||||||
case "ms":
|
|
||||||
return "毫秒"
|
|
||||||
case "second":
|
|
||||||
return "秒"
|
|
||||||
case "minute":
|
|
||||||
return "分钟"
|
|
||||||
case "hour":
|
|
||||||
return "小时"
|
|
||||||
case "day":
|
|
||||||
return "天"
|
|
||||||
case "week":
|
|
||||||
return "周 "
|
|
||||||
}
|
|
||||||
return unit
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `<div>
|
template: `<div>
|
||||||
@@ -118,27 +55,8 @@ Vue.component("http-cache-config-box", {
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div v-show="isOn()">
|
<div v-show="isOn()">
|
||||||
<table class="ui table selectable celled" v-show="cacheConfig.cacheRefs.length > 0">
|
<h4>缓存条件</h4>
|
||||||
<thead>
|
<http-cache-refs-config-box :v-cache-config="cacheConfig" :v-cache-refs="cacheConfig.cacheRefs"></http-cache-refs-config-box>
|
||||||
<tr>
|
|
||||||
<th>缓存条件</th>
|
|
||||||
<th class="width10">缓存时间</th>
|
|
||||||
<th class="two op">操作</th>
|
|
||||||
</tr>
|
|
||||||
<tr v-for="(cacheRef, index) in cacheConfig.cacheRefs">
|
|
||||||
<td>
|
|
||||||
<http-request-conds-view :v-conds="cacheRef.conds"></http-request-conds-view>
|
|
||||||
</td>
|
|
||||||
<td>{{cacheRef.life.count}} {{timeUnitName(cacheRef.life.unit)}}</td>
|
|
||||||
<td>
|
|
||||||
<a href="" @click.prevent="updateRef(index, cacheRef)">修改</a>
|
|
||||||
<a href="" @click.prevent="removeRef(index)">删除</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<button class="ui button tiny" @click.prevent="addRef">+添加缓存设置</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="margin"></div>
|
<div class="margin"></div>
|
||||||
</div>`
|
</div>`
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
Vue.component("http-cache-refs-config-box", {
|
Vue.component("http-cache-refs-config-box", {
|
||||||
props: ["v-cache-refs"],
|
props: ["v-cache-refs", "v-cache-config"],
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
let that = this
|
let that = this
|
||||||
sortTable(function (ids) {
|
sortTable(function (ids) {
|
||||||
@@ -12,6 +12,10 @@ Vue.component("http-cache-refs-config-box", {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
that.refs = newRefs
|
that.refs = newRefs
|
||||||
|
|
||||||
|
if (that.vCacheConfig != null) {
|
||||||
|
that.vCacheConfig.cacheRefs = newRefs
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
@@ -105,6 +109,7 @@ Vue.component("http-cache-refs-config-box", {
|
|||||||
<input type="hidden" name="refsJSON" :value="JSON.stringify(refs)"/>
|
<input type="hidden" name="refsJSON" :value="JSON.stringify(refs)"/>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
<p class="comment" v-if="refs.length == 0">暂时还没有缓存条件。</p>
|
||||||
<table class="ui table selectable celled" v-show="refs.length > 0" id="sortable-table">
|
<table class="ui table selectable celled" v-show="refs.length > 0" id="sortable-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ Vue.component("http-cond-url-prefix", {
|
|||||||
template: `<div>
|
template: `<div>
|
||||||
<input type="hidden" name="condJSON" :value="JSON.stringify(cond)"/>
|
<input type="hidden" name="condJSON" :value="JSON.stringify(cond)"/>
|
||||||
<input type="text" v-model="cond.value"/>
|
<input type="text" v-model="cond.value"/>
|
||||||
<p class="comment">URL前缀,通常以<code-label>/</code-label>开头,比如<code-label>/static</code-label>。</p>
|
<p class="comment">URL前缀,有此前缀的URL都将会被匹配,通常以<code-label>/</code-label>开头,比如<code-label>/static</code-label>。</p>
|
||||||
</div>`
|
</div>`
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ Vue.component("http-cond-url-not-prefix", {
|
|||||||
template: `<div>
|
template: `<div>
|
||||||
<input type="hidden" name="condJSON" :value="JSON.stringify(cond)"/>
|
<input type="hidden" name="condJSON" :value="JSON.stringify(cond)"/>
|
||||||
<input type="text" v-model="cond.value"/>
|
<input type="text" v-model="cond.value"/>
|
||||||
<p class="comment">要排除的URL前缀,通常以<code-label>/</code-label>开头,比如<code-label>/static</code-label>。</p>
|
<p class="comment">要排除的URL前缀,有此前缀的URL都将会被匹配,通常以<code-label>/</code-label>开头,比如<code-label>/static</code-label>。</p>
|
||||||
</div>`
|
</div>`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user