From 4923a3ccb1291a5159527f809ec95f67430686c2 Mon Sep 17 00:00:00 2001 From: theblind <1043193478@qq.com> Date: Sat, 5 Nov 2022 12:23:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=20=E6=89=93=E5=BC=80?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=96=B0=E4=BC=9A=E8=AF=9D=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=9C=89=E5=8F=AF=E8=83=BD=E6=B6=88=E6=81=AF=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E9=83=A8=E5=88=86=20#7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/views/shell/terminal/index.vue | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/ui/src/views/shell/terminal/index.vue b/ui/src/views/shell/terminal/index.vue index 7cba693..2cc2552 100644 --- a/ui/src/views/shell/terminal/index.vue +++ b/ui/src/views/shell/terminal/index.vue @@ -236,6 +236,15 @@ async function initConnect() { let connectState = false; const width = document.getElementById('container')?.offsetWidth; const height = document.getElementById('container')?.offsetHeight; + webSocket?.addMonitor(channelId, 'CMD', message => { + window.console.info(`CMD 接收 ${term}`); + term.write(message); + }); + + webSocket?.addMonitor(channelId, 'RETRIEVE_CMD', message => { + window.console.info(`RETRIEVE_CMD 接收`); + term.retrieve(JSON.parse(message)); + }); if (sessionId === undefined) { window.console.info('local'); const resultData = await localInitConnect(channelId, cols, rows, width, height); @@ -249,16 +258,6 @@ async function initConnect() { connectState = true; } } - webSocket?.connect(channelId, term); - webSocket?.addMonitor(channelId, 'CMD', message => { - window.console.info(`CMD 接收 ${term}`); - term.write(message); - }); - - webSocket?.addMonitor(channelId, 'RETRIEVE_CMD', message => { - window.console.info(`RETRIEVE_CMD 接收`); - term.retrieve(JSON.parse(message)); - }); return connectState; } @@ -299,7 +298,7 @@ onMounted(() => { const fontSize = 18; term = new Terminal({ rendererType: 'canvas', - name: 'terminal', + name: 'terminal'+channelId, rightClickSelectsWord: true, scrollback: 800, disableStdin: false,