Vue.component("user-agent-config-box", { props: ["v-is-location", "v-is-group", "value"], data: function () { let config = this.value if (config == null) { config = { isPrior: false, isOn: false, filters: [] } } if (config.filters == null) { config.filters = [] } return { config: config, isAdding: false, addingFilter: { keywords: [], action: "deny" }, moreOptionsVisible: false, batchKeywords: "" } }, methods: { isOn: function () { return ((!this.vIsLocation && !this.vIsGroup) || this.config.isPrior) && this.config.isOn }, remove: function (index) { let that = this teaweb.confirm("确定要删除此名单吗?", function () { that.config.filters.$remove(index) }) }, add: function () { this.isAdding = true let that = this setTimeout(function () { that.$refs.batchKeywords.focus() }) }, confirm: function () { if (this.addingFilter.action == "deny") { this.config.filters.push(this.addingFilter) } else { let index = -1 this.config.filters.forEach(function (filter, filterIndex) { if (filter.action == "allow") { index = filterIndex } }) if (index < 0) { this.config.filters.unshift(this.addingFilter) } else { this.config.filters.$insert(index + 1, this.addingFilter) } } this.cancel() }, cancel: function () { this.isAdding = false this.addingFilter = { keywords: [], action: "deny" } this.batchKeywords = "" }, changeKeywords: function (keywords) { let arr = keywords.split(/\n/) let resultKeywords = [] arr.forEach(function (keyword){ keyword = keyword.trim() if (!resultKeywords.$contains(keyword)) { resultKeywords.push(keyword) } }) this.addingFilter.keywords = resultKeywords }, showMoreOptions: function () { this.moreOptionsVisible = !this.moreOptionsVisible } }, template: `
启用UA名单

选中后表示开启UserAgent名单。

UA名单
UA关键词 动作 操作
{{keyword}} [空] 允许不允许 删除
UA关键词

每行一个关键词;不区分大小写,比如Chrome;支持*通配符,比如*Firefox*;也支持空行关键词,表示空UserAgent。

动作
 
例外URL

如果填写了例外URL,表示这些URL跳过5秒盾不做处理。

限制URL

如果填写了限制URL,表示只对这些URL进行5秒盾处理;如果不填则表示支持所有的URL。

` })