From 2bd289defac81583cb748b9e93d96be1677a87e4 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Mon, 10 Apr 2023 14:46:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=98=B2=E7=81=AB=E5=A2=99=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3=E6=A0=A1=E9=AA=8C=E8=A7=84=E5=88=99=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=20(#560)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/utils/util.ts | 3 +++ frontend/src/views/host/firewall/port/operate/index.vue | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts index 7f084482e..6ad3d8bcc 100644 --- a/frontend/src/utils/util.ts +++ b/frontend/src/utils/util.ts @@ -168,6 +168,9 @@ export function checkIp(value: string): boolean { } export function checkPort(value: string): boolean { + if (Number(value) <= 0) { + return true; + } const reg = /^([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5])$/; if (!reg.test(value) && value !== '') { return true; diff --git a/frontend/src/views/host/firewall/port/operate/index.vue b/frontend/src/views/host/firewall/port/operate/index.vue index 46368879b..bf5344f7f 100644 --- a/frontend/src/views/host/firewall/port/operate/index.vue +++ b/frontend/src/views/host/firewall/port/operate/index.vue @@ -123,9 +123,12 @@ const onSubmit = async (formEl: FormInstance | undefined) => { dialogData.value.rowData.address = ''; } let ports = []; - if (dialogData.value.rowData.port.indexOf('-') !== -1) { + if (dialogData.value.rowData.port.indexOf('-') !== -1 && !dialogData.value.rowData.port.startsWith('-')) { ports = dialogData.value.rowData.port.split('-'); - } else if (dialogData.value.rowData.port.indexOf(',') !== -1) { + } else if ( + dialogData.value.rowData.port.indexOf(',') !== -1 && + !dialogData.value.rowData.port.startsWith(',') + ) { ports = dialogData.value.rowData.port.split(','); } else { ports.push(dialogData.value.rowData.port);