mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-01-12 00:06:29 +08:00
fix: Fix node overview cannot operate container terminal issue (#11593)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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: '',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user