diff --git a/web/src/pages/group/List.vue b/web/src/pages/group/List.vue index 562c9368..8d1d221a 100644 --- a/web/src/pages/group/List.vue +++ b/web/src/pages/group/List.vue @@ -373,7 +373,7 @@ - 注意:域名拆分隧道,仅支持AnyConnect的桌面客户端,不支持移动端. + 注:域名拆分隧道,仅支持AnyConnect的桌面客户端,不支持移动端. @@ -412,13 +412,13 @@ :close-on-click-modal="false" title="编辑模式" :visible.sync="ipListDialog" - width="600px" + width="650px" custom-class="valgin-dialog" center> - - AnyConnect最多支持{{ this.maxRouteRows }}条路由,当前共 {{ ipEditForm.ip_list.split("\n").length }} 条 + + 当前共 {{ ipEditForm.ip_list.trim() === '' ? 0 : ipEditForm.ip_list.trim().split("\n").length }} 条(注:AnyConnect客户端最多支持{{ this.maxRouteRows }}条路由) 更新 @@ -686,23 +686,40 @@ export default { }, ipEdit() { this.ipEditLoading = true; - // ip_list不能超过this.maxRouteRows行 - if (this.ipEditForm.ip_list.split("\n").length > this.maxRouteRows) { - this.$message.error("错误:AnyConnect最多支持" + this.maxRouteRows + "条路由."); + let ipList = []; + if (this.ipEditForm.ip_list.trim() !== "") { + ipList = this.ipEditForm.ip_list.trim().split("\n"); + } + let arr = []; + for (let i = 0; i < ipList.length; i++) { + let item = ipList[i]; + let ip = item.split(","); + if (ip.length > 2) { + ip[1] = ip.slice(1).join(","); + } + let note = ip[1] ? ip[1] : ""; + const pushToArr = () => { + arr.push({val: ip[0], note: note}); + }; + if (this.ipEditForm.type == "route_include" && ip[0] == "all") { + pushToArr(); + continue; + } + if (!this.isValidCIDR(ip[0])) { + this.$message.error("错误:CIDR格式错误 " + item); this.ipEditLoading = false; - return false; + return; + } + pushToArr(); } - let arr = this.ipEditForm.ip_list.split("\n").map(item => { - let ip = item.split(","); - if (ip.length > 2) { - ip[1] = ip.slice(1).join(","); - } - return {val: ip[0], note: ip[1] ? ip[1] : ""}; - }); this.ruleForm[this.ipEditForm.type] = arr; this.ipEditLoading = false; this.ipListDialog = false; }, + isValidCIDR(str) { + const cidrRegex = /^([0-9]{1,3}\.){3}[0-9]{1,3}\/([0-9]|[1-2][0-9]|3[0-2])$/; + return cidrRegex.test(str); + }, resetForm(formName) { this.$refs[formName].resetFields(); },