fix: 解决数据库 dashboard 跳转失败的问题

This commit is contained in:
ssongliu 2022-12-07 18:38:52 +08:00
parent 9a214885c3
commit a6140aa647
6 changed files with 19 additions and 8 deletions

View File

@ -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;

View File

@ -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 () => {

View File

@ -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 () => {

View File

@ -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;

View File

@ -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;

View File

@ -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;