import React, { useState, useEffect } from 'react'; import { ChevronLeft, Bluetooth, RefreshCw, Zap, Smartphone, Wifi, Battery, Settings, Power, Activity, CheckCircle2 } from 'lucide-react'; interface DeviceManagerProps { onBack: () => void; } type ScanStatus = 'scanning' | 'found' | 'connected'; interface Device { id: string; name: string; signal: number; isPaired: boolean; } const DeviceManager: React.FC = ({ onBack }) => { const [status, setStatus] = useState('scanning'); const [scannedDevices, setScannedDevices] = useState([]); const [connectStep, setConnectStep] = useState(0); // 0: idle, 1: connecting, 2: success // Simulation: Scan for devices useEffect(() => { if (status === 'scanning') { const timer = setTimeout(() => { setScannedDevices([ { id: '1', name: 'Link-X Pro', signal: 92, isPaired: true }, { id: '2', name: 'Unknown Signal (Weak)', signal: 30, isPaired: false }, ]); setStatus('found'); }, 2500); return () => clearTimeout(timer); } }, [status]); const handleConnect = (device: Device) => { setConnectStep(1); // Simulate connection delay setTimeout(() => { setConnectStep(2); setTimeout(() => { setStatus('connected'); setConnectStep(0); }, 1000); }, 1500); }; const handleDisconnect = () => { if(window.confirm('确定要断开与设备的连接吗?')) { setStatus('scanning'); setScannedDevices([]); } }; const testVibration = () => { if (window.navigator.vibrate) { window.navigator.vibrate([200, 100, 200]); } alert('已发送震动测试指令'); }; // --- RENDER: Connected View --- if (status === 'connected') { return (
{/* Header */}

设备管理

{/* Device Visual Card */}
{/* Glowing Center */}

Link-X Pro

已连接
{/* Status Grid */}
剩余电量
85%
信号强度
-42dBm
{/* Actions */}

设备控制

); } // --- RENDER: Scanning View --- return (
{/* Header */}

搜索设备

{status === 'scanning' && }
{/* Radar Animation */}
{/* Rings */}
{/* Active Scan Line */} {status === 'scanning' && (
)} {/* Center Icon */}
{/* Status Text */}

{status === 'scanning' ? 'SCANNING FOR SIGNALS...' : 'SCAN COMPLETE'}

{/* Device List */}
{scannedDevices.map(device => ( ))}
{/* Help */}
请确保设备已开机并处于配对模式
{/* Full Screen Loading Overlay for Connection */} {connectStep === 2 && (

连接成功

)}
); }; export default DeviceManager;