Vue.component("http-cache-refs-config-box", { props: ["v-cache-refs", "v-cache-config", "v-cache-policy-id", "v-web-id"], mounted: function () { let that = this sortTable(function (ids) { let newRefs = [] ids.forEach(function (id) { that.refs.forEach(function (ref) { if (ref.id == id) { newRefs.push(ref) } }) }) that.updateRefs(newRefs) that.change() }) }, data: function () { let refs = this.vCacheRefs if (refs == null) { refs = [] } let id = 0 refs.forEach(function (ref) { id++ ref.id = id }) return { refs: refs, id: id // 用来对条件进行排序 } }, methods: { addRef: function (isReverse) { window.UPDATING_CACHE_REF = null let height = window.innerHeight if (height > 500) { height = 500 } let that = this teaweb.popup("/servers/server/settings/cache/createPopup?isReverse=" + (isReverse ? 1 : 0), { height: height + "px", callback: function (resp) { let newRef = resp.data.cacheRef if (newRef.conds == null) { return } that.id++ newRef.id = that.id if (newRef.isReverse) { let newRefs = [] let isAdded = false that.refs.forEach(function (v) { if (!v.isReverse && !isAdded) { newRefs.push(newRef) isAdded = true } newRefs.push(v) }) if (!isAdded) { newRefs.push(newRef) } that.updateRefs(newRefs) } else { that.refs.push(newRef) } that.change() } }) }, updateRef: function (index, cacheRef) { window.UPDATING_CACHE_REF = cacheRef let height = window.innerHeight if (height > 500) { height = 500 } let that = this teaweb.popup("/servers/server/settings/cache/createPopup", { height: height + "px", callback: function (resp) { resp.data.cacheRef.id = that.refs[index].id Vue.set(that.refs, index, resp.data.cacheRef) that.change() that.$refs.cacheRef[index].updateConds(resp.data.cacheRef.conds, resp.data.cacheRef.simpleCond) that.$refs.cacheRef[index].notifyChange() } }) }, disableRef: function (ref) { ref.isOn = false this.change() }, enableRef: function (ref) { ref.isOn = true this.change() }, removeRef: function (index) { let that = this teaweb.confirm("确定要删除此缓存设置吗?", function () { that.refs.$remove(index) that.change() }) }, updateRefs: function (newRefs) { this.refs = newRefs if (this.vCacheConfig != null) { this.vCacheConfig.cacheRefs = newRefs } }, 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 }, change: function () { this.$forceUpdate() // 自动保存 if (this.vCachePolicyId != null && this.vCachePolicyId > 0) { // 缓存策略 Tea.action("/servers/components/cache/updateRefs") .params({ cachePolicyId: this.vCachePolicyId, refsJSON: JSON.stringify(this.refs) }) .post() } else if (this.vWebId != null && this.vWebId > 0) { // Server Web or Group Web Tea.action("/servers/server/settings/cache/updateRefs") .params({ webId: this.vWebId, refsJSON: JSON.stringify(this.refs) }) .success(function (resp) { if (resp.data.isUpdated) { teaweb.successToast("保存成功") } }) .post() } } }, template: `
暂时还没有缓存条件。
| 缓存条件 | 分组关系 | 缓存时间 | 操作 | |
|---|---|---|---|---|
|
|
和 或 | {{cacheRef.life.count}} {{timeUnitName(cacheRef.life.unit)}} 不缓存 | 修改 暂停恢复 删除 |
所有条件匹配顺序为从上到下,可以拖动左侧的排序。服务设置的优先级比全局缓存策略设置的优先级要高。
+添加不缓存条件