From bd660f8c096fbba6160944db8c9fd7c06ad57c26 Mon Sep 17 00:00:00 2001 From: laihanbin <512412344@qq.com> Date: Thu, 14 Dec 2023 17:58:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0socket=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/Chinese-chess/.env | 2 +- packages/Chinese-chess/.env.production | 2 +- packages/Chinese-chess/src/composables/useSocket.ts | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/Chinese-chess/.env b/packages/Chinese-chess/.env index 689b382..f48b5df 100644 --- a/packages/Chinese-chess/.env +++ b/packages/Chinese-chess/.env @@ -1,2 +1,2 @@ VITE_APP_PATHNAME = / -VITE_SOCKET = ws://localhost:10086/ \ No newline at end of file +VITE_SOCKET = http://localhost:10086/ \ No newline at end of file diff --git a/packages/Chinese-chess/.env.production b/packages/Chinese-chess/.env.production index 65158f0..3f7c8f0 100644 --- a/packages/Chinese-chess/.env.production +++ b/packages/Chinese-chess/.env.production @@ -1,2 +1,2 @@ VITE_APP_PATHNAME = /mini-games/games/chinese-chess/ -VITE_SOCKET = wss://chess-service.humandetail.com/ \ No newline at end of file +VITE_SOCKET = https://chess-service.humandetail.com/ \ No newline at end of file diff --git a/packages/Chinese-chess/src/composables/useSocket.ts b/packages/Chinese-chess/src/composables/useSocket.ts index b3b7791..565267c 100644 --- a/packages/Chinese-chess/src/composables/useSocket.ts +++ b/packages/Chinese-chess/src/composables/useSocket.ts @@ -51,7 +51,9 @@ export const useSocket = ($: any) => { const isInit = computed(() => context.value?.status === GameStatus.Init) onMounted(() => { - socket.value = io(import.meta.env.VITE_SOCKET) + socket.value = io(import.meta.env.VITE_SOCKET, { + transports: ['websocket'] + }) socket.value.on(events.client.connect, () => { if (!currentUser.value) {