fix: Fix node overview cannot operate container terminal issue (#11593)

This commit is contained in:
ssongliu
2026-01-08 14:17:49 +08:00
committed by GitHub
parent 22055ed99a
commit e37d90d6e1
2 changed files with 10 additions and 4 deletions

View File

@@ -168,9 +168,11 @@ const initWebSocket = (endpoint_: string, args: string = '') => {
const protocol = href.split('//')[0] === 'http:' ? 'ws' : 'wss';
const host = href.split('//')[1].split('/')[0];
const endpoint = endpoint_.replace(/^\/+/, '');
terminalSocket.value = new WebSocket(
`${protocol}://${host}/${endpoint}?cols=${term.value.cols}&rows=${term.value.rows}&${args}&operateNode=${globalStore.currentNode}`,
);
let conn = `${protocol}://${host}/${endpoint}?cols=${term.value.cols}&rows=${term.value.rows}&${args}&operateNode=${globalStore.currentNode}`;
if (args.indexOf('&operateNode=') !== -1) {
conn = `${protocol}://${host}/${endpoint}?cols=${term.value.cols}&rows=${term.value.rows}&${args}`;
}
terminalSocket.value = new WebSocket(conn);
terminalSocket.value.onopen = runRealTerminal;
terminalSocket.value.onmessage = onWSReceive;
terminalSocket.value.onclose = closeRealTerminal;

View File

@@ -108,9 +108,13 @@ const initTerm = (formEl: FormInstance | undefined) => {
if (!valid) return;
terminalOpen.value = true;
await nextTick();
let args = `source=container&containerid=${form.containerID}&user=${form.user}&command=${form.command}`;
if (form.node) {
args += `&operateNode=${form.node}`;
}
terminalRef.value!.acceptParams({
endpoint: '/api/v2/containers/exec',
args: `source=container&containerid=${form.containerID}&user=${form.user}&command=${form.command}&node=${form.node}`,
args: args,
error: '',
initCmd: '',
});