// URL扩展名条件 Vue.component("http-cond-url-extension", { props: ["v-cond"], data: function () { let cond = { isRequest: true, param: "${requestPathExtension}", operator: "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: `
{{ext}}

扩展名需要包含点(.)符号,例如.jpg.png之类。

` }) // 根据URL前缀 Vue.component("http-cond-url-prefix", { props: ["v-cond"], data: function () { let cond = { isRequest: true, param: "${requestPath}", operator: "prefix", value: "" } if (this.vCond != null && typeof (this.vCond.value) == "string") { cond.value = this.vCond.value } return { cond: cond } }, template: `

URL前缀,有此前缀的URL都将会被匹配,通常以/开头,比如/static

` }) Vue.component("http-cond-url-not-prefix", { props: ["v-cond"], data: function () { let cond = { isRequest: true, param: "${requestPath}", operator: "prefix", value: "", isReverse: true } if (this.vCond != null && typeof this.vCond.value == "string") { cond.value = this.vCond.value } return { cond: cond } }, template: `

要排除的URL前缀,有此前缀的URL都将会被匹配,通常以/开头,比如/static

` }) // URL精准匹配 Vue.component("http-cond-url-eq", { props: ["v-cond"], data: function () { let cond = { isRequest: true, param: "${requestPath}", operator: "eq", value: "" } if (this.vCond != null && typeof this.vCond.value == "string") { cond.value = this.vCond.value } return { cond: cond } }, template: `

完整的URL路径,通常以/开头,比如/static/ui.js

` }) Vue.component("http-cond-url-not-eq", { props: ["v-cond"], data: function () { let cond = { isRequest: true, param: "${requestPath}", operator: "eq", value: "", isReverse: true } if (this.vCond != null && typeof this.vCond.value == "string") { cond.value = this.vCond.value } return { cond: cond } }, template: `

要排除的完整的URL路径,通常以/开头,比如/static/ui.js

` }) // URL正则匹配 Vue.component("http-cond-url-regexp", { props: ["v-cond"], data: function () { let cond = { isRequest: true, param: "${requestPath}", operator: "regexp", value: "" } if (this.vCond != null && typeof this.vCond.value == "string") { cond.value = this.vCond.value } return { cond: cond } }, template: `

匹配URL的正则表达式,比如^/static/(.*).js$

` }) // 排除URL正则匹配 Vue.component("http-cond-url-not-regexp", { props: ["v-cond"], data: function () { let cond = { isRequest: true, param: "${requestPath}", operator: "not regexp", value: "" } if (this.vCond != null && typeof this.vCond.value == "string") { cond.value = this.vCond.value } return { cond: cond } }, template: `

不要匹配URL的正则表达式,意即只要匹配成功则排除此条件,比如^/static/(.*).js$

` }) // 根据MimeType Vue.component("http-cond-mime-type", { props: ["v-cond"], data: function () { let cond = { isRequest: false, param: "${response.contentType}", operator: "mime type", value: "[]" } if (this.vCond != null && this.vCond.param == cond.param) { cond.value = this.vCond.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: `
{{mimeType}}

服务器返回的内容的MimeType,比如text/htmlimage/*等。

` })