mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-02 11:58:01 +08:00
websocket 自动识别协议
This commit is contained in:
parent
d3688d21d8
commit
55a6c385df
@ -43,4 +43,9 @@
|
||||
// 创建完后切换
|
||||
element.tabChange('mainTabs', lay_id);
|
||||
}
|
||||
|
||||
function getSocketHost() {
|
||||
var pro = location.protocol === 'https:' ? 'wss://' : 'ws://';
|
||||
return pro + window.location.host;
|
||||
}
|
||||
</script>
|
@ -90,7 +90,7 @@
|
||||
function loadSuccess() {
|
||||
const showLogDom = $('.console .terminal');
|
||||
if ('WebSocket' in window) {
|
||||
const ws = new WebSocket("ws://" + window.location.host + "/console/$userInfo/$!projectInfo.id");
|
||||
const ws = new WebSocket(getSocketHost() + "/console/$userInfo/$!projectInfo.id");
|
||||
ws.onopen = function () {
|
||||
showLogDom.append('WebSocket连接成功!<br/>');
|
||||
setMsg('status');
|
||||
|
@ -132,11 +132,11 @@
|
||||
|
||||
function linkSocket(status) {
|
||||
if (!ws) {
|
||||
ws = new WebSocket("ws://" + window.location.host + "/console/$userInfo/system");
|
||||
ws = new WebSocket(getSocketHost() + "/console/$userInfo/system");
|
||||
}
|
||||
if (status) {
|
||||
if (ws.readyState != 1 && ws.readyState != 0) {
|
||||
ws = new WebSocket("ws://" + window.location.host + "/console/$userInfo/system");
|
||||
ws = new WebSocket(getSocketHost() + "/console/$userInfo/system");
|
||||
}
|
||||
ws.onopen = function () {
|
||||
ws.send('{"op": "top", "projectInfo":{}}');
|
||||
|
Loading…
Reference in New Issue
Block a user