feat(core): 当页面为http时,自动使用ws协议连接web-socket
This commit is contained in:
@@ -27,12 +27,13 @@ Loader.init = function () {
|
|||||||
let url = '';
|
let url = '';
|
||||||
if (SOFTWARE.webCompiler?.url) {
|
if (SOFTWARE.webCompiler?.url) {
|
||||||
const info = new window.URL(SOFTWARE.webCompiler.url);
|
const info = new window.URL(SOFTWARE.webCompiler.url);
|
||||||
|
if (window.location.protocol === 'http:') {
|
||||||
|
info.protocol = 'ws:';
|
||||||
|
}
|
||||||
if (info.hostname === 'default') {
|
if (info.hostname === 'default') {
|
||||||
info.hostname = window.location.hostname;
|
info.hostname = window.location.hostname;
|
||||||
url = info.origin;
|
|
||||||
} else {
|
|
||||||
url = SOFTWARE.webCompiler.url;
|
|
||||||
}
|
}
|
||||||
|
url = info.origin;
|
||||||
} else {
|
} else {
|
||||||
url = `wss://${window.location.host}`;
|
url = `wss://${window.location.host}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,12 +33,13 @@ Loader.init = function () {
|
|||||||
let url = '';
|
let url = '';
|
||||||
if (SOFTWARE.webSocket?.url) {
|
if (SOFTWARE.webSocket?.url) {
|
||||||
const info = new window.URL(SOFTWARE.webSocket.url);
|
const info = new window.URL(SOFTWARE.webSocket.url);
|
||||||
|
if (window.location.protocol === 'http:') {
|
||||||
|
info.protocol = 'ws:';
|
||||||
|
}
|
||||||
if (info.hostname === 'default') {
|
if (info.hostname === 'default') {
|
||||||
info.hostname = window.location.hostname;
|
info.hostname = window.location.hostname;
|
||||||
url = info.origin;
|
|
||||||
} else {
|
|
||||||
url = SOFTWARE.webSocket.url;
|
|
||||||
}
|
}
|
||||||
|
url = info.origin;
|
||||||
} else {
|
} else {
|
||||||
url = `wss://${window.location.host}`;
|
url = `wss://${window.location.host}`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user