diff --git a/plugins/webssh/index.html b/plugins/webssh/index.html index 5f41875eb..6b0ad312e 100755 --- a/plugins/webssh/index.html +++ b/plugins/webssh/index.html @@ -2,7 +2,7 @@ $.getScript( "/plugins/file?name=webssh&f=js/webssh.js", function() { if ($(".term-box #term").text() != 'W') { layer.closeAll(); - web_shell(); + webShell(); } }); diff --git a/route/static/app/public.js b/route/static/app/public.js index 7ecf8383d..9495a9789 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -1201,6 +1201,204 @@ function loadImage(){ }); } + +function webShell() { + var termCols = 100; + var termRows = 29; + var sendTotal = 0; + if(!socket)socket = io.connect(); + var term = new Terminal({ cols: termCols, rows: termRows, screenKeys: true, useStyle: true}); + term.open(); + gterm = term + term.setOption('cursorBlink', true); + + socket.on('server_response', function (data) { + term.write(data.data); + + if (data.data == '\r\n登出\r\n' || data.data == '登出\r\n' || data.data == '\r\nlogout\r\n' || data.data == 'logout\r\n') { + setTimeout(function () { + layer.closeAll(); + }, 500); + } + }); + + if (socket) { + socket.emit('connect_event', ''); + interval = setInterval(function () { + socket.emit('connect_event', ''); + }, 1000); + } + + term.on('data', function (data) { + socket.emit('webssh', data); + }); + + + var term_box = layer.open({ + type: 1, + title: "宝塔终端", + area: ['920px','640px'], + closeBtn: 2, + shadeClose: false, + content: '
\ +
\ +