2020-09-29 11:28:39 +08:00
|
|
|
|
// URL扩展名条件
|
|
|
|
|
|
Vue.component("http-cond-url-extension", {
|
|
|
|
|
|
props: ["v-cond"],
|
|
|
|
|
|
data: function () {
|
|
|
|
|
|
let cond = this.vCond
|
|
|
|
|
|
if (cond == null) {
|
|
|
|
|
|
cond = {
|
2020-09-29 17:23:06 +08:00
|
|
|
|
isRequest: true,
|
2020-09-29 11:28:39 +08:00
|
|
|
|
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: `<div>
|
|
|
|
|
|
<input type="hidden" name="condJSON" :value="JSON.stringify(cond)"/>
|
|
|
|
|
|
<div v-if="extensions.length > 0">
|
|
|
|
|
|
<div class="ui label small" v-for="(ext, index) in extensions">{{ext}} <a href="" title="删除" @click.prevent="removeExt(index)"><i class="icon remove"></i></a></div>
|
|
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="ui fields inline" v-if="isAdding">
|
|
|
|
|
|
<div class="ui field">
|
|
|
|
|
|
<input type="text" size="6" maxlength="100" v-model="addingExt" ref="addingExt" placeholder=".xxx" @keyup.enter="confirmAdding" @keypress.enter.prevent="1" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="ui field">
|
|
|
|
|
|
<button class="ui button tiny" type="button" @click.prevent="confirmAdding">确认</button>
|
|
|
|
|
|
<a href="" title="取消" @click.prevent="cancelAdding"><i class="icon remove"></i></a>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<button class="ui button tiny" type="button" @click.prevent="addExt()">+添加扩展名</button>
|
|
|
|
|
|
<p class="comment">扩展名需要包含点(.)符号,例如<span class="ui label tiny">.jpg</span>、<span class="ui label tiny">.png</span>之类。</p>
|
|
|
|
|
|
</div>`
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2020-12-23 09:52:31 +08:00
|
|
|
|
// 根据URL前缀
|
|
|
|
|
|
Vue.component("http-cond-url-prefix", {
|
|
|
|
|
|
props: ["v-cond"],
|
|
|
|
|
|
data: function () {
|
|
|
|
|
|
let cond = this.vCond
|
|
|
|
|
|
if (cond == null) {
|
|
|
|
|
|
cond = {
|
|
|
|
|
|
isRequest: true,
|
|
|
|
|
|
param: "${requestPath}",
|
|
|
|
|
|
operator: "prefix",
|
|
|
|
|
|
value: ""
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
|
|
|
cond: cond
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
template: `<div>
|
|
|
|
|
|
<input type="hidden" name="condJSON" :value="JSON.stringify(cond)"/>
|
|
|
|
|
|
<input type="text" v-model="cond.value"/>
|
|
|
|
|
|
</div>`
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2021-05-12 15:07:30 +08:00
|
|
|
|
// URL精准匹配
|
|
|
|
|
|
Vue.component("http-cond-url-eq", {
|
|
|
|
|
|
props: ["v-cond"],
|
|
|
|
|
|
data: function () {
|
|
|
|
|
|
let cond = this.vCond
|
|
|
|
|
|
if (cond == null) {
|
|
|
|
|
|
cond = {
|
|
|
|
|
|
isRequest: true,
|
|
|
|
|
|
param: "${requestPath}",
|
|
|
|
|
|
operator: "eq",
|
|
|
|
|
|
value: ""
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
|
|
|
cond: cond
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
template: `<div>
|
|
|
|
|
|
<input type="hidden" name="condJSON" :value="JSON.stringify(cond)"/>
|
|
|
|
|
|
<input type="text" v-model="cond.value"/>
|
|
|
|
|
|
</div>`
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// URL正则匹配
|
|
|
|
|
|
Vue.component("http-cond-url-regexp", {
|
|
|
|
|
|
props: ["v-cond"],
|
|
|
|
|
|
data: function () {
|
|
|
|
|
|
let cond = this.vCond
|
|
|
|
|
|
if (cond == null) {
|
|
|
|
|
|
cond = {
|
|
|
|
|
|
isRequest: true,
|
|
|
|
|
|
param: "${requestPath}",
|
|
|
|
|
|
operator: "regexp",
|
|
|
|
|
|
value: ""
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
|
|
|
cond: cond
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
template: `<div>
|
|
|
|
|
|
<input type="hidden" name="condJSON" :value="JSON.stringify(cond)"/>
|
|
|
|
|
|
<input type="text" v-model="cond.value"/>
|
|
|
|
|
|
</div>`
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-29 11:28:39 +08:00
|
|
|
|
// 根据MimeType
|
|
|
|
|
|
Vue.component("http-cond-mime-type", {
|
|
|
|
|
|
props: ["v-cond"],
|
|
|
|
|
|
data: function () {
|
|
|
|
|
|
let cond = this.vCond
|
|
|
|
|
|
if (cond == null) {
|
|
|
|
|
|
cond = {
|
2020-09-29 17:23:06 +08:00
|
|
|
|
isRequest: false,
|
2020-09-29 11:28:39 +08:00
|
|
|
|
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: `<div>
|
|
|
|
|
|
<input type="hidden" name="condJSON" :value="JSON.stringify(cond)"/>
|
|
|
|
|
|
<div v-if="mimeTypes.length > 0">
|
|
|
|
|
|
<div class="ui label small" v-for="(mimeType, index) in mimeTypes">{{mimeType}} <a href="" title="删除" @click.prevent="removeMimeType(index)"><i class="icon remove"></i></a></div>
|
|
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="ui fields inline" v-if="isAdding">
|
|
|
|
|
|
<div class="ui field">
|
2020-09-29 17:23:06 +08:00
|
|
|
|
<input type="text" size="16" maxlength="100" v-model="addingMimeType" ref="addingMimeType" placeholder="类似于image/png" @keyup.enter="confirmAdding" @keypress.enter.prevent="1" />
|
2020-09-29 11:28:39 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="ui field">
|
|
|
|
|
|
<button class="ui button tiny" type="button" @click.prevent="confirmAdding">确认</button>
|
|
|
|
|
|
<a href="" title="取消" @click.prevent="cancelAdding"><i class="icon remove"></i></a>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<button class="ui button tiny" type="button" @click.prevent="addMimeType()">+添加MimeType</button>
|
|
|
|
|
|
<p class="comment">服务器返回的内容的MimeType,比如<span class="ui label tiny">text/html</span>、<span class="ui label tiny">image/*</span>等。</p>
|
|
|
|
|
|
</div>`
|
|
|
|
|
|
})
|