From 396312ece1b0125fc68d7d3b61e5459376a9d921 Mon Sep 17 00:00:00 2001 From: Apex Liu Date: Fri, 23 Mar 2018 17:05:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9Awebsocket=E5=8C=BA?= =?UTF-8?q?=E5=88=86http=E5=92=8Chttps=E4=B8=A4=E7=A7=8D=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/www/teleport/static/js/dashboard/dashboard.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/www/teleport/static/js/dashboard/dashboard.js b/server/www/teleport/static/js/dashboard/dashboard.js index 574639e..ec71ac5 100644 --- a/server/www/teleport/static/js/dashboard/dashboard.js +++ b/server/www/teleport/static/js/dashboard/dashboard.js @@ -457,7 +457,13 @@ $app.init_ws = function () { delete $app.ws; var _sid = Cookies.get('_sid'); - $app.ws = new WebSocket('ws://' + location.host + '/ws/' + _sid); + console.log(location); + console.log(location.host); + if(location.protocol === 'http') { + $app.ws = new WebSocket('ws://' + location.host + '/ws/' + _sid); + } else { + $app.ws = new WebSocket('wss://' + location.host + '/ws/' + _sid); + } $app.ws.onopen = function (e) { $app.ws.send('{"method": "request", "param": "sys_status"}');