From ed0923fd28ce202ba537a49618ace02efa4f188b Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Fri, 28 Jul 2023 18:23:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=9D=A2=E6=9D=BF=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=20(#1778)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/port-jump/index.vue | 4 ++-- frontend/src/global/form-rules.ts | 11 ++++++----- frontend/src/lang/modules/en.ts | 6 +++--- frontend/src/lang/modules/tw.ts | 6 +++--- frontend/src/lang/modules/zh.ts | 6 +++--- frontend/src/utils/util.ts | 12 ++++++++++++ frontend/src/views/container/volume/create/index.vue | 2 +- frontend/src/views/host/ssh/ssh/address/index.vue | 6 +++++- frontend/src/views/setting/panel/systemip/index.vue | 3 ++- 9 files changed, 37 insertions(+), 19 deletions(-) diff --git a/frontend/src/components/port-jump/index.vue b/frontend/src/components/port-jump/index.vue index 61d7ea154..2d2db5ba8 100644 --- a/frontend/src/components/port-jump/index.vue +++ b/frontend/src/components/port-jump/index.vue @@ -26,7 +26,7 @@ import { getSettingInfo } from '@/api/modules/setting'; import i18n from '@/lang'; import { MsgError } from '@/utils/message'; import { useRouter } from 'vue-router'; -import { checkIp } from '@/utils/util'; +import { checkDomain, checkIp } from '@/utils/util'; const router = useRouter(); const dialogVisiable = ref(); @@ -45,7 +45,7 @@ const acceptParams = async (params: DialogProps): Promise => { dialogVisiable.value = true; return; } - if (!checkIp(res.data.systemIP)) { + if (!checkIp(res.data.systemIP) || !checkDomain(res.data.systemIP)) { window.open(`http://${res.data.systemIP}:${params.port}`, '_blank'); return; } diff --git a/frontend/src/global/form-rules.ts b/frontend/src/global/form-rules.ts index 2af6f3a58..c8dd9cf5b 100644 --- a/frontend/src/global/form-rules.ts +++ b/frontend/src/global/form-rules.ts @@ -15,7 +15,7 @@ const checkIp = (rule: any, value: any, callback: any) => { } }; -const checkIpV4V6 = (rule: any, value: any, callback: any) => { +const checkIpV4V6OrDomain = (rule: any, value: any, callback: any) => { if (value === '' || typeof value === 'undefined' || value == null) { callback(new Error(i18n.global.t('commons.rule.requiredInput'))); } else { @@ -35,7 +35,8 @@ const checkIpV4V6 = (rule: any, value: any, callback: any) => { `(?::((?::${IPv6SegmentFormat}){0,5}:${IPv4AddressFormat}|(?::${IPv6SegmentFormat}){1,7}|:))` + ')(%[0-9a-zA-Z-.:]{1,})?$', ); - if (!IPv4AddressRegExp.test(value) && !IPv6AddressRegExp.test(value) && value !== '') { + const regHost = /^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/; + if (!regHost.test(value) && !IPv4AddressRegExp.test(value) && !IPv6AddressRegExp.test(value) && value !== '') { callback(new Error(i18n.global.t('commons.rule.ip'))); } else { callback(); @@ -429,7 +430,7 @@ interface CommonRule { integerNumberWith0: FormItemRule; floatNumber: FormItemRule; ip: FormItemRule; - ipV4V6: FormItemRule; + ipV4V6OrDomain: FormItemRule; host: FormItemRule; illegal: FormItemRule; port: FormItemRule; @@ -546,8 +547,8 @@ export const Rules: CommonRule = { required: true, trigger: 'blur', }, - ipV4V6: { - validator: checkIpV4V6, + ipV4V6OrDomain: { + validator: checkIpV4V6OrDomain, required: true, trigger: 'blur', }, diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 0d0909c6e..ceea4b500 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -165,6 +165,7 @@ const message = { integer: 'Please enter the correct positive integer', ip: 'Please enter the correct IP address', host: 'Enter the correct IP address or domain name', + hostHelper: 'Support input of IP address or domain', port: 'Please enter the correct port', selectHelper: 'Please select the correct {0} file', domain: 'domain name format error', @@ -590,7 +591,6 @@ const message = { volumeDir: 'Volume dir', nfsEnable: 'Enable NFS storage', nfsAddress: 'Address', - nfsAddressHelper: 'Support input of IP address or domain', mountpoint: 'Mountpoint', mountpointNFSHelper: 'e.g. /nfs, /nfs-share', options: 'Options', @@ -961,8 +961,8 @@ const message = { sessionTimeoutError: 'The minimum timeout is 300 seconds', sessionTimeoutHelper: 'If you do not operate the panel for more than {0} seconds, the panel automatically logs out', - systemIP: 'System IP', - systemIPWarning: 'The server IP is not currently set. Please set it in the control panel first!', + systemIP: 'System Address', + systemIPWarning: 'The server address is not currently set. Please set it in the control panel first!', syncTime: 'Server time', timeZone: 'Time Zone', timeZoneChangeHelper: 'Changing the time zone requires restarting the service. Do you want to continue?', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 23c033f7b..dd997ba51 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -165,6 +165,7 @@ const message = { integer: '請輸入正確的正整數', ip: '請輸入正確的 IP 地址', host: '請輸入正確的 IP 或者域名', + hostHelper: '支持輸入 ip 或者域名', port: '請輸入正確的端口,1-65535', selectHelper: '請選擇正確的 {0} 文件', domain: '域名格式錯誤', @@ -580,7 +581,6 @@ const message = { volumeDir: '存儲卷目錄', nfsEnable: '啟用 NFS 存儲', nfsAddress: '地址', - nfsAddressHelper: '支持輸入 ip 或者域名', mountpoint: '掛載點', mountpointNFSHelper: '例:/nfs, /nfs-share', options: '可選參數', @@ -929,8 +929,8 @@ const message = { sessionTimeout: '超時時間', sessionTimeoutError: '最小超時時間為 300 秒', sessionTimeoutHelper: '如果用戶超過 {0} 秒未操作面板,面板將自動退出登錄', - systemIP: '服務器 IP', - systemIPWarning: '當前未設置服務器 IP,請先在面板設置中設置!', + systemIP: '服務器地址', + systemIPWarning: '當前未設置服務器地址,請先在面板設置中設置!', syncTime: '服務器時間', timeZone: '系統時區', timeZoneChangeHelper: '系統時區修改需要重啟服務,是否繼續?', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index a8fe9620e..7e3225a60 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -165,6 +165,7 @@ const message = { integer: '请输入正确的正整数', ip: '请输入正确的 IP 地址', host: '请输入正确的 IP 或者域名', + hostHelper: '支持输入 ip 或者域名', port: '请输入正确的端口,1-65535', selectHelper: '请选择正确的 {0} 文件', domain: '域名格式错误', @@ -580,7 +581,6 @@ const message = { volumeDir: '存储卷目录', nfsEnable: '启用 NFS 存储', nfsAddress: '地址', - nfsAddressHelper: '支持输入 ip 或者域名', mountpoint: '挂载点', mountpointNFSHelper: '例:/nfs, /nfs-share', options: '可选参数', @@ -929,8 +929,8 @@ const message = { sessionTimeout: '超时时间', sessionTimeoutError: '最小超时时间为 300 秒', sessionTimeoutHelper: '如果用户超过 {0} 秒未操作面板,面板将自动退出登录', - systemIP: '服务器 IP', - systemIPWarning: '当前未设置服务器 IP,请先在面板设置中设置!', + systemIP: '服务器地址', + systemIPWarning: '当前未设置服务器地址,请先在面板设置中设置!', syncTime: '服务器时间', timeZone: '系统时区', timeZoneChangeHelper: '系统时区修改需要重启服务,是否继续?', diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts index b2e3fadbf..6db703eb0 100644 --- a/frontend/src/utils/util.ts +++ b/frontend/src/utils/util.ts @@ -185,6 +185,18 @@ export function checkIp(value: string): boolean { } } +export function checkDomain(value: string): boolean { + if (value === '') { + return true; + } + const reg = /^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/; + if (!reg.test(value) && value !== '') { + return true; + } else { + return false; + } +} + export function checkIpV4V6(value: string): boolean { if (value === '') { return true; diff --git a/frontend/src/views/container/volume/create/index.vue b/frontend/src/views/container/volume/create/index.vue index 8443ee5e5..e8a452ff9 100644 --- a/frontend/src/views/container/volume/create/index.vue +++ b/frontend/src/views/container/volume/create/index.vue @@ -28,7 +28,7 @@ diff --git a/frontend/src/views/host/ssh/ssh/address/index.vue b/frontend/src/views/host/ssh/ssh/address/index.vue index 279c76e96..f7c1704cd 100644 --- a/frontend/src/views/host/ssh/ssh/address/index.vue +++ b/frontend/src/views/host/ssh/ssh/address/index.vue @@ -13,7 +13,11 @@ - + diff --git a/frontend/src/views/setting/panel/systemip/index.vue b/frontend/src/views/setting/panel/systemip/index.vue index f66c2da52..179df16e2 100644 --- a/frontend/src/views/setting/panel/systemip/index.vue +++ b/frontend/src/views/setting/panel/systemip/index.vue @@ -7,8 +7,9 @@ - + + {{ $t('commons.rule.hostHelper') }}