From d0b20620bb0c6b8c6909c431a1bfd7ce168e4462 Mon Sep 17 00:00:00 2001 From: zyh Date: Thu, 6 Jul 2023 17:20:04 +0800 Subject: [PATCH] =?UTF-8?q?perf=EF=BC=9A=E4=BC=98=E5=8C=96url=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/page/config/setup.vue | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/nezha-fronted/src/components/page/config/setup.vue b/nezha-fronted/src/components/page/config/setup.vue index 7ae393f8e..75c01e256 100644 --- a/nezha-fronted/src/components/page/config/setup.vue +++ b/nezha-fronted/src/components/page/config/setup.vue @@ -383,7 +383,7 @@ export default { if (this.redis.mode === 'standalone') { this.$set(this.redis, 'url', [{ ip: '', port: 6379 }]) } else if (this.redis.mode === 'sentinel') { - this.$set(this.redis, 'url', [{ ip: '', port: 6379 }, { ip: '', port: 6379 }, { ip: '', port: 6379 }]) + this.$set(this.redis, 'url', [{ ip: '', port: 6379 }, { ip: '', port: 6379 }, { ip: '', port: 6379 }, { ip: '', port: 6379 }]) } else if (this.redis.mode === 'dms') { this.$set(this.redis, 'url', [{ ip: '', port: 6379 }, { ip: '', port: 6379 }]) } @@ -421,17 +421,14 @@ export default { if (flag && urlArr.some((item, index) => item === urlArr[currentIndex] && index != currentIndex)) { callback(new Error('URL ' + this.$t('validate.duplicate'))) } else { - const arr = urlArr.filter(item => { - const ip = item.split(':')[0] - const port = item.split(':')[1] - return ipReg.test(ip) && !isNaN(Number(port)) && !(port < 1 || port > 65535) - }) // 没有重复的 则清除校验 - if (arr.length == new Set(arr).size) { - urlArr.forEach((item, index) => { + urlArr.forEach((item, index) => { + const findIndex = urlArr.indexOf(item) + const lastIndex = urlArr.lastIndexOf(item) + if (findIndex == lastIndex) { this.$refs[formName].clearValidate('urlItem' + index) - }) - } + } + }) callback() } },