- {/* 如果已经加入房间(hasShownJoinSuccess)或获取到文字内容,将文字输入框显示在上方 */}
- {(receivedText !== '' || textContent || hasShownJoinSuccess) && (
-
-
-
- {isConnected && (
-
- )}
- {isWebSocketConnected && !isConnected && (
-
- )}
- {!isWebSocketConnected && !isConnected && (
-
- )}
-
-
-
- )}
-
- {/* 只有在未加入房间时才显示输入框和加入按钮 */}
- {!(receivedText !== '' || textContent || hasShownJoinSuccess) && (
- <>
-
setRoomCode(e.target.value.toUpperCase().slice(0, 6))}
- placeholder="请输入房间码"
- className="text-center text-2xl sm:text-3xl tracking-[0.3em] sm:tracking-[0.5em] font-mono h-12 sm:h-16 border-2 border-slate-200 rounded-xl focus:border-emerald-500 focus:ring-emerald-500 bg-white/80 backdrop-blur-sm"
- maxLength={6}
- disabled={isLoading}
- />
-
-
- >
- )}
-
- {/* 接收方显示接收到的图片 */}
- {mode === 'receive' && receivedImages.length > 0 && (
-
-
-
- 接收到的图片 ({receivedImages.length})
-
-
- {receivedImages.map((img, index) => (
-
-

setPreviewImage(img)}
- onLoad={(e) => {
- console.log(`图片 ${index + 1} 加载成功`);
- }}
- onError={(e) => {
- console.error(`图片 ${index + 1} 加载失败:`, img.substring(0, 100));
- e.currentTarget.style.backgroundColor = '#f1f5f9';
- e.currentTarget.style.display = 'flex';
- e.currentTarget.style.alignItems = 'center';
- e.currentTarget.style.justifyContent = 'center';
- e.currentTarget.innerHTML = `
图片加载失败`;
- }}
- />
- {/* 悬浮按钮组 */}
-
-
-
-
-
- {/* 图片序号 */}
-
- {index + 1}
-
-
- ))}
-
-
- )}
-