import { X, Ruler, Activity, Radar } from 'lucide-react'; import { useState } from 'react'; import { Modal, message, Spin } from 'antd'; import { request } from '../utils/request'; import type { CelestialBody } from '../types'; interface FocusInfoProps { body: CelestialBody | null; onClose: () => void; } export function FocusInfo({ body, onClose }: FocusInfoProps) { const [showTerminal, setShowTerminal] = useState(false); const [terminalData, setTerminalData] = useState(''); const [loading, setLoading] = useState(false); if (!body) return null; // Calculate distance if position is available const pos = body.positions[0]; const distance = pos ? Math.sqrt(pos.x ** 2 + pos.y ** 2 + pos.z ** 2).toFixed(2) : '---'; const isProbe = body.type === 'probe'; const isActive = body.is_active !== false; const fetchNasaData = async () => { setShowTerminal(true); setLoading(true); try { const { data } = await request.get(`/celestial/${body.id}/nasa-data`); setTerminalData(data.raw_data); } catch (err) { console.error(err); message.error('连接 NASA Horizons 失败'); // If failed, maybe show error in terminal setTerminalData("CONNECTION FAILED.\n\nError establishing link with JPL Horizons System.\nCheck connection frequencies."); } finally { setLoading(false); } }; const terminalStyles = ` .terminal-modal .ant-modal-content { background-color: #0d1117 !important; border: 1px solid #238636 !important; box-shadow: 0 0 30px rgba(35, 134, 54, 0.15) !important; color: #2ea043 !important; padding: 0 !important; overflow: hidden !important; } .terminal-modal .ant-modal-body { background-color: #0d1117 !important; } .terminal-modal .ant-modal-header { background-color: #161b22 !important; border-bottom: 1px solid #238636 !important; margin-bottom: 0 !important; } .terminal-modal .ant-modal-title { color: #2ea043 !important; } .terminal-modal .ant-modal-close { color: #2ea043 !important; } .terminal-modal .ant-modal-close:hover { background-color: rgba(35, 134, 54, 0.2) !important; } .terminal-modal .ant-modal-body .animate-in { color: #2ea043 !important; /* Ensure content text is green */ } @keyframes spin-slow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } .animate-spin-slow { animation: spin-slow 3s linear infinite; } `; return ( // Remove fixed positioning, now handled by parent container (Html component in 3D)
{/* Main Info Card */}
{/* Close Button */} {/* Header */}

{body.name_zh || body.name}

{isProbe ? '探测器' : '天体'}

{body.description || '暂无描述'}

{/* Stats and Actions Grid */}
{/* Column 1: Heliocentric Distance Card */}
日心距离
{distance} AU
{/* Column 2: JPL Horizons Button */}
{/* Conditional Probe Status Card (if isProbe is true, this goes in a new row) */} {isProbe && (
状态
{isActive ? '运行中' : '已失效'}
)}
{/* Connecting Line/Triangle pointing down to the body */}
{/* Terminal Modal */} setShowTerminal(false)} footer={null} width={800} centered className="terminal-modal" styles={{ header: { backgroundColor: '#161b22', borderBottom: '1px solid #238636', padding: '12px 20px', marginBottom: 0, display: 'flex', alignItems: 'center' }, mask: { backgroundColor: 'rgba(0, 0, 0, 0.85)', backdropFilter: 'blur(4px)' }, body: { padding: '20px', backgroundColor: '#0d1117' } }} title={
JPL/HORIZONS SYSTEM INTERFACE // {body.name.toUpperCase()}
} closeIcon={} >
{loading ? (
} />
ESTABLISHING SECURE UPLINK...
Connecting to ssd.jpl.nasa.gov...
) : (
{terminalData}
)}
); }