From e1d163f80ce7db1b7e56e7fc134d5e43f05e116f Mon Sep 17 00:00:00 2001 From: MatrixSeven Date: Mon, 11 Aug 2025 10:04:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dws=E4=B8=BB=E5=8A=A8?= =?UTF-8?q?=E6=96=AD=E5=BC=80=E9=97=AE=E9=A2=98|=E7=B2=BE=E7=AE=80?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E9=80=BB=E8=BE=91=EF=BC=8C=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=E7=8A=B6=E6=80=81=E5=92=8C?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/WebRTCFileTransfer.tsx | 4 -- .../components/webrtc/WebRTCTextReceiver.tsx | 9 +++-- .../hooks/webrtc/useSharedWebRTCManager.ts | 37 +++++++++---------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/chuan-next/src/components/WebRTCFileTransfer.tsx b/chuan-next/src/components/WebRTCFileTransfer.tsx index 5fd3441..a478bd9 100644 --- a/chuan-next/src/components/WebRTCFileTransfer.tsx +++ b/chuan-next/src/components/WebRTCFileTransfer.tsx @@ -50,11 +50,7 @@ export const WebRTCFileTransfer: React.FC = () => { isConnected, isConnecting, isWebSocketConnected, - connectionError, - isTransferring, - progress, error, - receivedFiles, connect, disconnect, sendFile, diff --git a/chuan-next/src/components/webrtc/WebRTCTextReceiver.tsx b/chuan-next/src/components/webrtc/WebRTCTextReceiver.tsx index a2ad1f1..9d78baa 100644 --- a/chuan-next/src/components/webrtc/WebRTCTextReceiver.tsx +++ b/chuan-next/src/components/webrtc/WebRTCTextReceiver.tsx @@ -42,10 +42,11 @@ export const WebRTCTextReceiver: React.FC = ({ // 连接所有传输通道 const connectAll = useCallback(async (code: string, role: 'sender' | 'receiver') => { console.log('=== 连接所有传输通道 ===', { code, role }); - await Promise.all([ - textTransfer.connect(code, role), - fileTransfer.connect(code, role) - ]); + await connection.connect(code, role); + // await Promise.all([ + // textTransfer.connect(code, role), + // fileTransfer.connect(code, role) + // ]); }, [textTransfer, fileTransfer]); // 是否有任何连接 diff --git a/chuan-next/src/hooks/webrtc/useSharedWebRTCManager.ts b/chuan-next/src/hooks/webrtc/useSharedWebRTCManager.ts index 68e2e91..4d0cb4a 100644 --- a/chuan-next/src/hooks/webrtc/useSharedWebRTCManager.ts +++ b/chuan-next/src/hooks/webrtc/useSharedWebRTCManager.ts @@ -1,4 +1,3 @@ -import { UrlSource } from './../../../node_modules/lightningcss/node/ast.d'; import { useState, useRef, useCallback } from 'react'; import { config } from '@/lib/config'; @@ -85,28 +84,28 @@ export function useSharedWebRTCManager(): WebRTCConnection { // 清理连接 const cleanup = useCallback(() => { - console.log('[SharedWebRTC] 清理连接'); - if (timeoutRef.current) { - clearTimeout(timeoutRef.current); - timeoutRef.current = null; - } + // console.log('[SharedWebRTC] 清理连接'); + // if (timeoutRef.current) { + // clearTimeout(timeoutRef.current); + // timeoutRef.current = null; + // } - if (dcRef.current) { - dcRef.current.close(); - dcRef.current = null; - } + // if (dcRef.current) { + // dcRef.current.close(); + // dcRef.current = null; + // } - if (pcRef.current) { - pcRef.current.close(); - pcRef.current = null; - } + // if (pcRef.current) { + // pcRef.current.close(); + // pcRef.current = null; + // } - if (wsRef.current) { - wsRef.current.close(); - wsRef.current = null; - } + // if (wsRef.current) { + // wsRef.current.close(); + // wsRef.current = null; + // } - currentRoom.current = null; + // currentRoom.current = null; }, []); // 创建 Offer