File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -32,10 +32,6 @@ const token = computed(() => {
3232 return Session .getToken ();
3333});
3434
35- const tenant = computed (() => {
36- return Session .getTenant ();
37- });
38-
3935onMounted (() => {
4036 initWebSocket ();
4137});
@@ -50,7 +46,9 @@ const initWebSocket = () => {
5046 let host = window .location .host ;
5147 // baseURL
5248 let baseURL = import .meta .env .VITE_API_URL ;
53- let wsUri = ` ws://${host }${baseURL }${other .adaptationUrl (props .uri )}?access_token=${token .value }&TENANT-ID=${tenant .value } ` ;
49+ // 自动判断协议:如果当前页面是 https,则使用 wss,否则使用 ws
50+ let protocol = window .location .protocol === ' https:' ? ' wss:' : ' ws:' ;
51+ let wsUri = ` ${protocol }//${host }${baseURL }${other .adaptationUrl (props .uri )}?access_token=${token .value } ` ;
5452 // 建立连接
5553 state .webSocket = new WebSocket (wsUri );
5654 // 连接成功
You can’t perform that action at this time.
0 commit comments