Vue.component("http-firewall-captcha-options", { props: ["v-captcha-options"], mounted: function () { this.updateSummary() }, data: function () { let options = this.vCaptchaOptions if (options == null) { options = { captchaType: "default", countLetters: 0, life: 0, maxFails: 0, failBlockTimeout: 0, failBlockScopeAll: false, uiIsOn: false, uiTitle: "", uiPrompt: "", uiButtonTitle: "", uiShowRequestId: true, uiCss: "", uiFooter: "", uiBody: "", cookieId: "", lang: "" } } if (options.countLetters <= 0) { options.countLetters = 6 } if (options.captchaType == null || options.captchaType.length == 0) { options.captchaType = "default" } return { options: options, isEditing: false, summary: "", uiBodyWarning: "", captchaTypes: window.WAF_CAPTCHA_TYPES } }, watch: { "options.countLetters": function (v) { let i = parseInt(v, 10) if (isNaN(i)) { i = 0 } else if (i < 0) { i = 0 } else if (i > 10) { i = 10 } this.options.countLetters = i }, "options.life": function (v) { let i = parseInt(v, 10) if (isNaN(i)) { i = 0 } this.options.life = i this.updateSummary() }, "options.maxFails": function (v) { let i = parseInt(v, 10) if (isNaN(i)) { i = 0 } this.options.maxFails = i this.updateSummary() }, "options.failBlockTimeout": function (v) { let i = parseInt(v, 10) if (isNaN(i)) { i = 0 } this.options.failBlockTimeout = i this.updateSummary() }, "options.failBlockScopeAll": function (v) { this.updateSummary() }, "options.captchaType": function (v) { this.updateSummary() }, "options.uiIsOn": function (v) { this.updateSummary() }, "options.uiBody": function (v) { if (/
标签包裹\${body}变量,否则将导致验证码表单无法提交。" } else { this.uiBodyWarning = "" } } }, methods: { edit: function () { this.isEditing = !this.isEditing }, updateSummary: function () { let summaryList = [] if (this.options.life > 0) { summaryList.push("有效时间" + this.options.life + "秒") } if (this.options.maxFails > 0) { summaryList.push("最多失败" + this.options.maxFails + "次") } if (this.options.failBlockTimeout > 0) { summaryList.push("失败拦截" + this.options.failBlockTimeout + "秒") } if (this.options.failBlockScopeAll) { summaryList.push("全局封禁") } let that = this let typeDef = this.captchaTypes.$find(function (k, v) { return v.code == that.options.captchaType }) if (typeDef != null) { summaryList.push("默认验证方式:" + typeDef.name) } if (this.options.captchaType == "default") { if (this.options.uiIsOn) { summaryList.push("定制UI") } } if (summaryList.length == 0) { this.summary = "默认配置" } else { this.summary = summaryList.join(" / ") } }, confirm: function () { this.isEditing = false } }, template: `| 默认验证方式 |
{{captchaDef.description}} |
| 有效时间 |
秒
验证通过后在这个时间内不再验证,默认600秒。 |
| 最多失败次数 |
次
建议填入一个不小于5的数字,以减少误判几率。允许用户失败尝试的最多次数,超过这个次数将被自动加入黑名单。如果为空或者为0,表示不限制。 |
| 失败拦截时间 |
秒
在达到最多失败次数(大于0)时,自动拦截的时长;如果为0表示不自动拦截。 |
| 失败全局封禁 |
是否在失败时全局封禁,默认为只封禁对单个网站的访问。 |
| 验证码中数字个数 | |
| 定制UI | |
| 页面标题 | |
| 按钮标题 |
类似于 |
| 显示请求ID |
在界面上显示请求ID,方便用户报告问题。 |
| CSS样式 | |
| 页头提示 |
类似于 |
| 页尾提示 |
支持HTML。 |
| 页面模板 |
警告:{{uiBodyWarning}}模板中必须包含\${body}表示验证码表单!整个页面的模板,支持HTML,其中必须使用 |