diff --git a/frontend/src/views/container/container/terminal/index.vue b/frontend/src/views/container/container/terminal/index.vue index aca275b91..6d058de9b 100644 --- a/frontend/src/views/container/container/terminal/index.vue +++ b/frontend/src/views/container/container/terminal/index.vue @@ -117,6 +117,8 @@ const initTerm = (formEl: FormInstance | undefined) => { if (!formEl) return; formEl.validate(async (valid) => { if (!valid) return; + let href = window.location.href; + let ipLocal = href.split('//')[1].split(':')[0]; terminalOpen.value = true; let ifm = document.getElementById('terminal-exec') as HTMLInputElement | null; term = new Terminal({ @@ -134,7 +136,7 @@ const initTerm = (formEl: FormInstance | undefined) => { if (ifm) { term.open(ifm); terminalSocket = new WebSocket( - `ws://localhost:9999/api/v1/containers/exec?containerid=${form.containerID}&cols=${term.cols}&rows=${term.rows}&user=${form.user}&command=${form.command}`, + `ws://${ipLocal}:9999/api/v1/containers/exec?containerid=${form.containerID}&cols=${term.cols}&rows=${term.rows}&user=${form.user}&command=${form.command}`, ); terminalSocket.onopen = runRealTerminal; terminalSocket.onmessage = onWSReceive; diff --git a/frontend/src/views/database/mysql/index.vue b/frontend/src/views/database/mysql/index.vue index fa45a7c8f..3e8d9a3f8 100644 --- a/frontend/src/views/database/mysql/index.vue +++ b/frontend/src/views/database/mysql/index.vue @@ -245,7 +245,9 @@ const goDashboard = async () => { phpVisiable.value = true; return; } - window.open('http://localhost:' + phpadminPort.value, '_blank'); + let href = window.location.href; + let ipLocal = href.split('//')[1].split(':')[0]; + window.open(`http://${ipLocal}:${phpadminPort.value}`, '_blank'); }; const loadDashboardPort = async () => { diff --git a/frontend/src/views/database/redis/index.vue b/frontend/src/views/database/redis/index.vue index ff18aaf89..d2ac276cf 100644 --- a/frontend/src/views/database/redis/index.vue +++ b/frontend/src/views/database/redis/index.vue @@ -67,7 +67,9 @@ const goDashboard = async () => { commandVisiable.value = true; return; } - window.open('http://localhost:' + redisCommandPort.value, '_blank'); + let href = window.location.href; + let ipLocal = href.split('//')[1].split(':')[0]; + window.open(`http://${ipLocal}:${redisCommandPort.value}`, '_blank'); }; const loadDashboardPort = async () => { diff --git a/frontend/src/views/database/redis/terminal/index.vue b/frontend/src/views/database/redis/terminal/index.vue index d6da4cdea..655efd828 100644 --- a/frontend/src/views/database/redis/terminal/index.vue +++ b/frontend/src/views/database/redis/terminal/index.vue @@ -69,7 +69,8 @@ const closeRealTerminal = (ev: CloseEvent) => { const initTerm = () => { let ifm = document.getElementById('terminal-exec') as HTMLInputElement | null; - console.log(ifm); + let href = window.location.href; + let ipLocal = href.split('//')[1].split(':')[0]; term = new Terminal({ lineHeight: 1.2, fontSize: 12, @@ -85,7 +86,7 @@ const initTerm = () => { if (ifm) { term.open(ifm); terminalSocket = new WebSocket( - `ws://localhost:9999/api/v1/databases/redis/exec?cols=${term.cols}&rows=${term.rows}`, + `ws://${ipLocal}:9999/api/v1/databases/redis/exec?cols=${term.cols}&rows=${term.rows}`, ); terminalSocket.onopen = runRealTerminal; terminalSocket.onmessage = onWSReceive; diff --git a/frontend/src/views/host/file-management/process/index.vue b/frontend/src/views/host/file-management/process/index.vue index 44382f66a..9113d3a78 100644 --- a/frontend/src/views/host/file-management/process/index.vue +++ b/frontend/src/views/host/file-management/process/index.vue @@ -55,7 +55,9 @@ const onerror = () => {}; const onClose = () => {}; const initProcess = () => { - processSocket = new WebSocket(`ws://localhost:9999/api/v1/files/ws`); + let href = window.location.href; + let ipLocal = href.split('//')[1].split(':')[0]; + processSocket = new WebSocket(`ws://${ipLocal}:9999/api/v1/files/ws`); processSocket.onopen = onOpenProcess; processSocket.onmessage = onMessage; processSocket.onerror = onerror; diff --git a/frontend/src/views/host/terminal/terminal/terminal.vue b/frontend/src/views/host/terminal/terminal/terminal.vue index 8c1b8b989..052a0fd54 100644 --- a/frontend/src/views/host/terminal/terminal/terminal.vue +++ b/frontend/src/views/host/terminal/terminal/terminal.vue @@ -59,6 +59,8 @@ const closeRealTerminal = (ev: CloseEvent) => { const initTerm = () => { let ifm = document.getElementById('terminal' + props.terminalID) as HTMLInputElement | null; + let href = window.location.href; + let ipLocal = href.split('//')[1].split(':')[0]; term = new Terminal({ lineHeight: 1.2, fontSize: 12, @@ -75,11 +77,11 @@ const initTerm = () => { term.open(ifm); if (props.wsID === 0) { terminalSocket = new WebSocket( - `ws://localhost:9999/api/v1/terminals/local?cols=${term.cols}&rows=${term.rows}`, + `ws://${ipLocal}:9999/api/v1/terminals/local?cols=${term.cols}&rows=${term.rows}`, ); } else { terminalSocket = new WebSocket( - `ws://localhost:9999/api/v1/terminals?id=${props.wsID}&cols=${term.cols}&rows=${term.rows}`, + `ws://${ipLocal}:9999/api/v1/terminals?id=${props.wsID}&cols=${term.cols}&rows=${term.rows}`, ); } terminalSocket.onopen = runRealTerminal;