fix: WebSocket连接根据页面协议自动选择ws/wss,修复HTTPS下Mixed Content报错

This commit is contained in:
qinglong
2026-06-14 19:39:36 +08:00
parent cd45372141
commit 26d515e080
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -50,7 +50,8 @@ window.DashboardModule = {
}
var base = window.location.pathname.split("/").slice(0, 2).join("/");
var ws = new WebSocket("ws://" + location.host + base + "/api/system/ws");
var proto = location.protocol === 'https:' ? 'wss://' : 'ws://';
var ws = new WebSocket(proto + location.host + base + "/api/system/ws");
self.ws = ws;
ws.onopen = function() {