mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 12:20:28 +08:00
69 lines
2.5 KiB
JavaScript
69 lines
2.5 KiB
JavaScript
// 显示WAF规则的标签
|
||
Vue.component("http-firewall-rule-label", {
|
||
props: ["v-rule"],
|
||
data: function () {
|
||
return {
|
||
rule: this.vRule
|
||
}
|
||
},
|
||
methods: {
|
||
showErr: function (err) {
|
||
teaweb.popupTip("规则校验错误,请修正:<span class=\"red\">" + teaweb.encodeHTML(err) + "</span>")
|
||
},
|
||
operatorName: function (operatorCode) {
|
||
let operatorName = operatorCode
|
||
if (typeof (window.WAF_RULE_OPERATORS) != null) {
|
||
window.WAF_RULE_OPERATORS.forEach(function (v) {
|
||
if (v.code == operatorCode) {
|
||
operatorName = v.name
|
||
}
|
||
})
|
||
}
|
||
|
||
return operatorName
|
||
},
|
||
operatorDataType: function (operatorCode) {
|
||
let operatorDataType = "none"
|
||
if (typeof (window.WAF_RULE_OPERATORS) != null) {
|
||
window.WAF_RULE_OPERATORS.forEach(function (v) {
|
||
if (v.code == operatorCode) {
|
||
operatorDataType = v.dataType
|
||
}
|
||
})
|
||
}
|
||
|
||
return operatorDataType
|
||
},
|
||
isEmptyString: function (v) {
|
||
return typeof v == "string" && v.length == 0
|
||
}
|
||
},
|
||
template: `<div>
|
||
<div class="ui label tiny basic" style="line-height: 1.5">
|
||
{{rule.name}}[{{rule.param}}]
|
||
|
||
<!-- cc2 -->
|
||
<span v-if="rule.param == '\${cc2}'">
|
||
{{rule.checkpointOptions.period}}秒内请求数
|
||
</span>
|
||
|
||
<!-- refererBlock -->
|
||
<span v-if="rule.param == '\${refererBlock}'">
|
||
<span v-if="rule.checkpointOptions.allowDomains != null && rule.checkpointOptions.allowDomains.length > 0">允许{{rule.checkpointOptions.allowDomains}}</span>
|
||
<span v-if="rule.checkpointOptions.denyDomains != null && rule.checkpointOptions.denyDomains.length > 0">禁止{{rule.checkpointOptions.denyDomains}}</span>
|
||
</span>
|
||
|
||
<span v-else>
|
||
<span v-if="rule.paramFilters != null && rule.paramFilters.length > 0" v-for="paramFilter in rule.paramFilters"> | {{paramFilter.code}}</span>
|
||
<span :class="{dash:!rule.isComposed && rule.isCaseInsensitive}" :title="(!rule.isComposed && rule.isCaseInsensitive) ? '大小写不敏感':''">{{operatorName(rule.operator)}}</span>
|
||
<span v-if="!isEmptyString(rule.value)">{{rule.value}}</span>
|
||
<span v-else-if="operatorDataType(rule.operator) != 'none'" class="disabled" style="font-weight: normal" title="空字符串">[空]</span>
|
||
</span>
|
||
|
||
<!-- description -->
|
||
<span v-if="rule.description != null && rule.description.length > 0" class="grey small">({{rule.description}})</span>
|
||
|
||
<a href="" v-if="rule.err != null && rule.err.length > 0" @click.prevent="showErr(rule.err)" style="color: #db2828; opacity: 1; border-bottom: 1px #db2828 dashed; margin-left: 0.5em">规则错误</a>
|
||
</div>
|
||
</div>`
|
||
}) |