fix(修改前台ws、wss自动判断)

style(readme)
This commit is contained in:
浪子小新
2020-03-31 20:20:27 +08:00
parent 2702810e4b
commit b2617a7e04
2 changed files with 23 additions and 1 deletions
+3 -1
View File
@@ -5,7 +5,9 @@ var webSocketClick = {
init:function(){
var __this = this;
__this.app_block = $(".app-block");
__this.ws = new WebSocket("wss://" + document.domain + ":8848");
var ishttps = 'https:' == document.location.protocol ? true: false;
__this.ws = new WebSocket("ws" + (ishttps ? "s": "") + "://" + document.domain + ":8848");
// __this.ws = new WebSocket("ws" + (ishttps ? "s": "") + "://" + document.domain + "/wss"); //nginx配置ssl做8848转发
__this.ws.onopen = function(event){
__this.onOpen(event)
}