From cb6b9965ec42b89b20f1979f25517863b794e160 Mon Sep 17 00:00:00 2001
From: ssongliu <73214554+ssongliu@users.noreply.github.com>
Date: Thu, 7 Dec 2023 14:36:07 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=B9=E5=99=A8=E7=AB=AF=E5=8F=A3?=
 =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E5=A2=9E=E5=8A=A0=20IPv4=20IPv6=20=E5=88=A4?=
 =?UTF-8?q?=E6=96=AD=20(#3212)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 frontend/src/components/port-jump/index.vue    | 18 +++++++++++++-----
 frontend/src/lang/modules/en.ts                |  1 +
 frontend/src/lang/modules/tw.ts                |  1 +
 frontend/src/lang/modules/zh.ts                |  1 +
 .../src/views/container/container/index.vue    |  7 +++++--
 frontend/src/views/database/redis/index.vue    |  2 ++
 6 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/frontend/src/components/port-jump/index.vue b/frontend/src/components/port-jump/index.vue
index 4bfe5bcf6..43d3e8a6a 100644
--- a/frontend/src/components/port-jump/index.vue
+++ b/frontend/src/components/port-jump/index.vue
@@ -24,15 +24,15 @@
 import { ref } from 'vue';
 import { getSettingInfo } from '@/api/modules/setting';
 import i18n from '@/lang';
-import { MsgError } from '@/utils/message';
+import { MsgError, MsgWarning } from '@/utils/message';
 import { useRouter } from 'vue-router';
-import { checkDomain, checkIp } from '@/utils/util';
 const router = useRouter();
 
 const dialogVisible = ref();
 
 interface DialogProps {
     port: any;
+    ip: string;
     protocol: string;
 }
 
@@ -47,11 +47,19 @@ const acceptParams = async (params: DialogProps): Promise<void> => {
         dialogVisible.value = true;
         return;
     }
-    if (!checkIp(res.data.systemIP) || !checkDomain(res.data.systemIP)) {
+    if (res.data.systemIP.indexOf(':') === -1) {
+        if (params.ip && params.ip === 'ipv6') {
+            MsgWarning(i18n.global.t('setting.systemIPWarning1', ['IPv4']));
+            return;
+        }
         window.open(`${protocol}://${res.data.systemIP}:${params.port}`, '_blank');
-        return;
+    } else {
+        if (params.ip && params.ip === 'ipv4') {
+            MsgWarning(i18n.global.t('setting.systemIPWarning1', ['IPv6']));
+            return;
+        }
+        window.open(`${protocol}://[${res.data.systemIP}]:${params.port}`, '_blank');
     }
-    window.open(`${protocol}://[${res.data.systemIP}]:${params.port}`, '_blank');
 };
 
 const goRouter = async (path: string) => {
diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts
index 831d2768a..f5f28cb2c 100644
--- a/frontend/src/lang/modules/en.ts
+++ b/frontend/src/lang/modules/en.ts
@@ -1180,6 +1180,7 @@ const message = {
             'If you do not operate the panel for more than {0} seconds, the panel automatically logs out',
         systemIP: 'System Address',
         systemIPWarning: 'The server address is not currently set. Please set it in the control panel first!',
+        systemIPWarning1: 'The current server address is set to {0}, and quick redirection is not possible!',
         defaultNetwork: 'Network Card',
         syncTime: 'Server Time',
         timeZone: 'Time Zone',
diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts
index 0c8173ec2..8739efddc 100644
--- a/frontend/src/lang/modules/tw.ts
+++ b/frontend/src/lang/modules/tw.ts
@@ -1121,6 +1121,7 @@ const message = {
         sessionTimeoutHelper: '如果用戶超過 {0} 秒未操作面板,面板將自動退出登錄',
         systemIP: '服務器地址',
         systemIPWarning: '當前未設置服務器地址,請先在面板設置中設置!',
+        systemIPWarning1: '當前服務器地址設置為 {0},無法快速跳轉!',
         defaultNetwork: '默認網卡',
         changePassword: '密碼修改',
         oldPassword: '原密碼',
diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts
index 21a952e61..df98a36d5 100644
--- a/frontend/src/lang/modules/zh.ts
+++ b/frontend/src/lang/modules/zh.ts
@@ -1122,6 +1122,7 @@ const message = {
         sessionTimeoutHelper: '如果用户超过 {0} 秒未操作面板,面板将自动退出登录',
         systemIP: '服务器地址',
         systemIPWarning: '当前未设置服务器地址,请先在面板设置中设置!',
+        systemIPWarning1: '当前服务器地址设置为 {0},无法快速跳转!',
         defaultNetwork: '默认网卡',
         changePassword: '密码修改',
         oldPassword: '原密码',
diff --git a/frontend/src/views/container/container/index.vue b/frontend/src/views/container/container/index.vue
index 77f5f38a8..52d328753 100644
--- a/frontend/src/views/container/container/index.vue
+++ b/frontend/src/views/container/container/index.vue
@@ -330,12 +330,15 @@ const goDashboard = async (port: any) => {
         MsgWarning(i18n.global.t('container.unExposedPort'));
         return;
     }
-    if (!port || port.indexOf(':') === -1 || port.indexOf('->') === -1) {
+    if (port.indexOf(':') === -1) {
         MsgWarning(i18n.global.t('commons.msg.errPort'));
         return;
     }
     let portEx = port.match(/:(\d+)/)[1];
-    dialogPortJumpRef.value.acceptParams({ port: portEx });
+
+    let matches = port.match(new RegExp(':', 'g'));
+    let ip = matches && matches.length > 1 ? 'ipv6' : 'ipv4';
+    dialogPortJumpRef.value.acceptParams({ port: portEx, ip: ip });
 };
 
 const goSetting = async () => {
diff --git a/frontend/src/views/database/redis/index.vue b/frontend/src/views/database/redis/index.vue
index f31b10f14..845a2b267 100644
--- a/frontend/src/views/database/redis/index.vue
+++ b/frontend/src/views/database/redis/index.vue
@@ -128,6 +128,7 @@ const checkExist = (data: App.CheckInstalled) => {
                 endpoint: '/api/v1/databases/redis/exec',
                 args: '',
                 error: '',
+                initCmd: '',
             });
         });
     }
@@ -141,6 +142,7 @@ const initTerminal = async () => {
                 endpoint: '/api/v1/databases/redis/exec',
                 args: '',
                 error: '',
+                initCmd: '',
             });
         });
     }