@@ -28,7 +28,6 @@ import * as search from 'xterm/lib/addons/search/search'
2828
2929import ' xterm/lib/addons/fullscreen/fullscreen.css'
3030import ' xterm/dist/xterm.css'
31- // import config from '@/config/config'
3231
3332const defaultTheme = {
3433 foreground: ' #ffffff' , // 字体
@@ -54,13 +53,14 @@ const defaultTheme = {
5453}
5554const bindTerminalResize = (term , websocket ) => {
5655 const onTermResize = size => {
57- websocket .send (
58- JSON .stringify ({
59- type: ' resize' ,
60- rows: size .rows ,
61- cols: size .cols
62- })
63- )
56+ // websocket.send(
57+ // JSON.stringify({
58+ // type: 'resize',
59+ // rows: size.rows,
60+ // cols: size.cols
61+ // })
62+ // )
63+ websocket .send (' 2' + Base64 .encode (size .rows + ' :' + size .cols ))
6464 }
6565 // register resize event.
6666 term .on (' resize' , onTermResize)
@@ -95,9 +95,9 @@ const bindTerminal = (term, websocket, bidirectional, bufferedTime) => {
9595 // cmd: Base64.encode(data) // encode data as base64 format
9696 // })
9797 // )
98- websocket .send (data)
98+ websocket .send (' 0 ' + Base64 . encode ( data) )
9999
100- term .write (data)
100+ // term.write(data)
101101 }
102102
103103 websocket .onmessage = handleWebSocketMessage
@@ -108,7 +108,7 @@ const bindTerminal = (term, websocket, bidirectional, bufferedTime) => {
108108 // send heartbeat package to avoid closing webSocket connection in some proxy environmental such as nginx.
109109 const heartBeatTimer = setInterval (function () {
110110 // websocket.send(JSON.stringify({ type: 'heartbeat', data: '' }))
111- websocket .send (' ping \r\n ' )
111+ websocket .send (' 1 ' )
112112 }, 20 * 1000 )
113113
114114 websocket .addEventListener (' close' , function () {
0 commit comments