Sfoglia il codice sorgente

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

疯狂的狮子Li 1 anno fa
parent
commit
35bebf403c
1 ha cambiato i file con 2 aggiunte e 1 eliminazioni
  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) => {