Skip to content

Commit

Permalink
修复: 打开一个新会话时,有可能消息丢失部分 #7
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlindM committed Nov 5, 2022
1 parent 290a909 commit 4923a3c
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions ui/src/views/shell/terminal/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -299,7 +298,7 @@ onMounted(() => {
const fontSize = 18;
term = new Terminal({
rendererType: 'canvas',
name: 'terminal',
name: 'terminal'+channelId,
rightClickSelectsWord: true,
scrollback: 800,
disableStdin: false,
Expand Down

0 comments on commit 4923a3c

Please sign in to comment.