Vue.component("cache-cond-box", { data: function () { return { conds: [], addingExt: false, addingPath: false, extDuration: null, pathDuration: null } }, methods: { addExt: function () { this.addingExt = !this.addingExt this.addingPath = false if (this.addingExt) { let that = this setTimeout(function () { if (that.$refs.extInput != null) { that.$refs.extInput.focus() } }) } }, changeExtDuration: function (duration) { this.extDuration = duration }, confirmExt: function () { let value = this.$refs.extInput.value if (value.length == 0) { return } let exts = [] let pieces = value.split(/[,,]/) pieces.forEach(function (v) { v = v.trim() v = v.replace(/\s+/, "") if (v.length > 0) { if (v[0] != ".") { v = "." + v } exts.push(v) } }) this.conds.push({ type: "url-extension", value: JSON.stringify(exts), duration: this.extDuration }) this.$refs.extInput.value = "" this.cancel() }, addPath: function () { this.addingExt = false this.addingPath = !this.addingPath if (this.addingPath) { let that = this setTimeout(function () { if (that.$refs.pathInput != null) { that.$refs.pathInput.focus() } }) } }, changePathDuration: function (duration) { this.pathDuration = duration }, confirmPath: function () { let value = this.$refs.pathInput.value if (value.length == 0) { return } if (value[0] != "/") { value = "/" + value } this.conds.push({ type: "url-prefix", value: value, duration: this.pathDuration }) this.$refs.pathInput.value = "" this.cancel() }, remove: function (index) { this.conds.$remove(index) }, cancel: function () { this.addingExt = false this.addingPath = false } }, template: `
扩展名 路径:{{cond.value}}   ()  
确定  
确定  
 
` })