diff --git a/web/public/js/components/server/http-cond-definitions.js b/web/public/js/components/server/http-cond-definitions.js index 9b71e0c2..8f7a1935 100644 --- a/web/public/js/components/server/http-cond-definitions.js +++ b/web/public/js/components/server/http-cond-definitions.js @@ -89,6 +89,97 @@ Vue.component("http-cond-url-extension", { ` }) +// URL扩展名条件 +Vue.component("http-cond-url-not-extension", { + props: ["v-cond"], + data: function () { + let cond = { + isRequest: true, + param: "${requestPathExtension}", + operator: "not in", + value: "[]" + } + if (this.vCond != null && this.vCond.param == cond.param) { + cond.value = this.vCond.value + } + + let extensions = [] + try { + extensions = JSON.parse(cond.value) + } catch (e) { + + } + + return { + cond: cond, + extensions: extensions, // 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, "").toLowerCase() + this.extensions.push(this.addingExt) + + // 清除状态 + this.cancelAdding() + }, + removeExt: function (index) { + this.extensions.$remove(index) + } + }, + template: `
` +}) + // 根据URL前缀 Vue.component("http-cond-url-prefix", { props: ["v-cond"], diff --git a/web/public/js/conds/official.json b/web/public/js/conds/official.json index 1ae89cb7..d58b82c0 100644 --- a/web/public/js/conds/official.json +++ b/web/public/js/conds/official.json @@ -51,6 +51,14 @@ "paramsTitle": "参数配置", "isRequest": true }, + { + "type": "url-not-extension", + "name": "排除:URL扩展名", + "description": "根据URL中的文件路径扩展名进行过滤", + "component": "http-cond-url-not-extension", + "paramsTitle": "扩展名列表", + "isRequest": true + }, { "type": "url-not-prefix", "name": "排除:URL前缀",