diff --git a/web/public/js/components/common/url-patterns-box.js b/web/public/js/components/common/url-patterns-box.js new file mode 100644 index 00000000..0efb8142 --- /dev/null +++ b/web/public/js/components/common/url-patterns-box.js @@ -0,0 +1,104 @@ +Vue.component("url-patterns-box", { + props: ["value"], + data: function () { + let patterns = [] + if (this.value != null) { + patterns = this.value + } + return { + patterns: patterns, + isAdding: false, + + addingPattern: {"type": "wildcard", "pattern": ""}, + editingIndex: -1 + } + }, + methods: { + add: function () { + this.isAdding = true + let that = this + setTimeout(function () { + that.$refs.patternInput.focus() + }) + }, + edit: function (index) { + this.isAdding = true + this.editingIndex = index + this.addingPattern = { + type: this.patterns[index].type, + pattern: this.patterns[index].pattern + } + }, + confirm: function () { + let pattern = this.addingPattern.pattern.trim() + if (pattern.length == 0) { + let that = this + teaweb.warn("请输入URL", function () { + that.$refs.patternInput.focus() + }) + return + } + if (this.editingIndex < 0) { + this.patterns.push({ + type: this.addingPattern.type, + pattern: this.addingPattern.pattern + }) + } else { + this.patterns[this.editingIndex].type = this.addingPattern.type + this.patterns[this.editingIndex].pattern = this.addingPattern.pattern + } + this.notifyChange() + this.cancel() + }, + remove: function (index) { + this.patterns.$remove(index) + this.cancel() + this.notifyChange() + }, + cancel: function () { + this.isAdding = false + this.addingPattern = {"type": "wildcard", "pattern": ""} + this.editingIndex = -1 + }, + patternTypeName: function (patternType) { + switch (patternType) { + case "wildcard": + return "通配符" + case "regexp": + return "正则" + } + return "" + }, + notifyChange: function () { + this.$emit("input", this.patterns) + } + }, + template: `
+
+
+ [{{patternTypeName(pattern.type)}}] {{pattern.pattern}}   + + +
+
+
+
+
+ +
+
+ +
+
+   +
+
+
+
+ +
+
` +}) \ No newline at end of file diff --git a/web/public/js/components/server/server-uam.js b/web/public/js/components/server/server-uam.js index 3ecb1ea0..abab00f0 100644 --- a/web/public/js/components/server/server-uam.js +++ b/web/public/js/components/server/server-uam.js @@ -6,11 +6,25 @@ Vue.component("uam-config-box", { if (config == null) { config = { isPrior: false, - isOn: false + isOn: false, + onlyURLPatterns: [], + exceptURLPatterns: [] } } + if (config.onlyURLPatterns == null) { + config.onlyURLPatterns = [] + } + if (config.exceptURLPatterns == null) { + config.exceptURLPatterns = [] + } return { - config: config + config: config, + moreOptionsVisible: false + } + }, + methods: { + showMoreOptions: function () { + this.moreOptionsVisible = !this.moreOptionsVisible } }, template: `
@@ -26,6 +40,28 @@ Vue.component("uam-config-box", { + + + + + + + + 例外URL + + +

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

+ + + + 限制URL + + +

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

+ + + +
`