mirror of
https://github.com/MatrixSeven/file-transfer-go.git
synced 2026-05-14 07:29:36 +08:00
feat: 调整UI/RTC逻辑
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useState, useCallback, useRef } from 'react';
|
||||
import { FileInfo, TransferProgress } from '@/types';
|
||||
import { useState, useCallback } from 'react';
|
||||
import { TransferProgress } from '@/types';
|
||||
import { useToast } from '@/components/ui/toast-simple';
|
||||
|
||||
interface FileTransferData {
|
||||
|
||||
@@ -20,9 +20,9 @@ export function useWebRTCTransfer() {
|
||||
|
||||
// 设置数据通道消息处理
|
||||
useEffect(() => {
|
||||
const dataChannel = connection.getDataChannel();
|
||||
const dataChannel = connection.localDataChannel || connection.remoteDataChannel;
|
||||
if (dataChannel && dataChannel.readyState === 'open') {
|
||||
console.log('设置数据通道消息处理器');
|
||||
console.log('设置数据通道消息处理器, 通道类型:', connection.localDataChannel ? '本地' : '远程');
|
||||
|
||||
// 扩展消息处理以包含文件列表
|
||||
const originalHandler = fileTransfer.handleMessage;
|
||||
@@ -50,7 +50,7 @@ export function useWebRTCTransfer() {
|
||||
originalHandler(event);
|
||||
};
|
||||
}
|
||||
}, [connection.isConnected, connection.getDataChannel, fileTransfer.handleMessage]);
|
||||
}, [connection.localDataChannel, connection.remoteDataChannel, fileTransfer.handleMessage]);
|
||||
|
||||
// 发送文件
|
||||
const sendFile = useCallback((file: File, fileId?: string) => {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user