Skip to content

Commit

Permalink
websocket支持https协议
Browse files Browse the repository at this point in the history
  • Loading branch information
cgw committed Oct 23, 2023
1 parent 171dba1 commit fb81dc3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion static/js/terminal/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WSSHClient.prototype._generateEndpoint = function () {
} else {
var protocol = 'ws://';
}
var endpoint = protocol + window.location.hostname +':'+ window.location.port + '/terminal';
var endpoint = protocol + window.location.host + '/terminal';
return endpoint;
};

Expand Down
7 changes: 5 additions & 2 deletions static/page/deployment_detail/log.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@

var loginToken = getCookie('login_token');
var appId = localStorage.getItem('appId_' + parent.layui.$("#userName").val());
//var websocket = new WebSocket('ws://'+ window.location.hostname +':'+ window.location.port +'/deployment/log/'+ parent.id +'/'+ appId + '/' + loginToken);
var websocket = new WebSocket('ws://'+ window.location.hostname +':'+ window.location.port +'/deployment/log');
var ws = 'ws://';
if(window.location.protocol == 'https:'){
ws = 'wss://';
}
var websocket = new WebSocket(ws + window.location.host +'/deployment/log');
websocket.onopen = function(event) {
websocket.send(JSON.stringify({"appId": appId, "deploymentDetailId": parent.id, "loginToken": loginToken}));
};
Expand Down
6 changes: 5 additions & 1 deletion static/page/deployment_version/log.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@

var loginToken = getCookie('login_token');
var appId = localStorage.getItem('appId_' + parent.layui.$("#userName").val());
var websocket = new WebSocket('ws://'+ window.location.hostname +':'+ window.location.port +'/build/log');
var ws = 'ws://';
if(window.location.protocol == 'https:'){
ws = 'wss://';
}
var websocket = new WebSocket(ws + window.location.host +'/build/log');
websocket.onopen = function(event) {
websocket.send(JSON.stringify({"appId": appId, "id": parent.id, "loginToken": loginToken}));
};
Expand Down
6 changes: 5 additions & 1 deletion static/page/replica/log.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
var loginToken = getCookie('login_token');
var replicaName = parent.replicaName;
var appId = localStorage.getItem('appId_' + parent.layui.$("#userName").val());
var websocket = new WebSocket('ws://'+ window.location.hostname +':'+ window.location.port +'/replica/log/'+ replicaName +'/' + loginToken);
var ws = 'ws://';
if(window.location.protocol == 'https:'){
ws = 'wss://';
}
var websocket = new WebSocket(ws + window.location.host +'/replica/log/'+ replicaName +'/' + loginToken);
websocket.onmessage = function(event) {
$("#log-container div").append(event.data);
$("#log-container").scrollTop($("#log-container div").height() - $("#log-container").height());
Expand Down

0 comments on commit fb81dc3

Please sign in to comment.