// URL扩展名条件 Vue.component("http-cond-url-extension", { props: ["v-cond"], data: function () { let cond = this.vCond if (cond == null) { cond = { isRequest: true, param: "${requestPathExtension}", operator: "in", value: "[]" } } return { cond: cond, extensions: JSON.parse(cond.value), // TODO 可以拖动排序 isAdding: false, addingExt: "" } }, watch: { extensions: function () { this.cond.value = JSON.stringify(this.extensions) } }, methods: { addExt: function () { this.isAdding = !this.isAdding if (this.isAdding) { let that = this setTimeout(function () { that.$refs.addingExt.focus() }, 100) } }, cancelAdding: function () { this.isAdding = false this.addingExt = "" }, confirmAdding: function () { // TODO 做更详细的校验 // TODO 如果有重复的则提示之 if (this.addingExt.length == 0) { return } if (this.addingExt[0] != ".") { this.addingExt = "." + this.addingExt } this.addingExt = this.addingExt.replace(/\s+/g, "") this.extensions.push(this.addingExt) // 清除状态 this.cancelAdding() }, removeExt: function (index) { this.extensions.$remove(index) } }, template: `
` }) // 根据MimeType Vue.component("http-cond-mime-type", { props: ["v-cond"], data: function () { let cond = this.vCond if (cond == null) { cond = { isRequest: false, param: "${response.contentType}", operator: "mime type", value: "[]" } } return { cond: cond, mimeTypes: JSON.parse(cond.value), // TODO 可以拖动排序 isAdding: false, addingMimeType: "" } }, watch: { mimeTypes: function () { this.cond.value = JSON.stringify(this.mimeTypes) } }, methods: { addMimeType: function () { this.isAdding = !this.isAdding if (this.isAdding) { let that = this setTimeout(function () { that.$refs.addingMimeType.focus() }, 100) } }, cancelAdding: function () { this.isAdding = false this.addingMimeType = "" }, confirmAdding: function () { // TODO 做更详细的校验 // TODO 如果有重复的则提示之 if (this.addingMimeType.length == 0) { return } this.addingMimeType = this.addingMimeType.replace(/\s+/g, "") this.mimeTypes.push(this.addingMimeType) // 清除状态 this.cancelAdding() }, removeMimeType: function (index) { this.mimeTypes.$remove(index) } }, template: `` })