Quellcode durchsuchen

update 适配 websocket在https下的连接方式

疯狂的狮子Li vor 1 Jahr
Ursprung
Commit
35bebf403c
1 geänderte Dateien mit 2 neuen und 1 gelöschten Zeilen
  1. 2 1
      src/views/index.vue

+ 2 - 1
src/views/index.vue

@@ -99,7 +99,8 @@
 import { initWebSocket } from '@/utils/websocket';
 
 onMounted(() => {
-  initWebSocket("ws://" + window.location.host + import.meta.env.VITE_APP_BASE_API + "/resource/websocket");
+  let protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://'
+  initWebSocket(protocol + window.location.host + import.meta.env.VITE_APP_BASE_API + "/resource/websocket");
 });
 
 const goTarget = (url:string) => {