diff --git a/src/hooks/websocket.ts b/src/hooks/websocket.ts index 0c53fa4..5db488a 100644 --- a/src/hooks/websocket.ts +++ b/src/hooks/websocket.ts @@ -12,8 +12,8 @@ const useAdminWebSocket = () => { // ws地址 const baseUri = import.meta.env.VITE_API_URL - const host = window.location.host - const wsUri = `ws://${host}${baseUri}/ws?access_token=${accessToken}` + const protocol = window.location.protocol || '' + const wsUri = `${protocol.startsWith('https') ? 'wss' : 'ws'}://${host}${baseUri}/ws?access_token=${accessToken}` useWebSocketReturn = useWebSocket(wsUri, { autoReconnect: {