import React, { useState, useEffect } from 'react'; import { Download, Smartphone, Monitor, Apple, ChevronRight, Cpu } from 'lucide-react'; import apiClient from '../utils/apiClient'; import { buildApiUrl, API_ENDPOINTS } from '../config/api'; import './ClientDownloads.css'; const ClientDownloads = () => { const [clients, setClients] = useState({ mobile: [], desktop: [], terminal: [] }); const [loading, setLoading] = useState(true); useEffect(() => { fetchLatestClients(); }, []); const fetchLatestClients = async () => { setLoading(true); try { const response = await apiClient.get(buildApiUrl(API_ENDPOINTS.CLIENT_DOWNLOADS.LATEST)); console.log('Latest clients response:', response); setClients(response.data || { mobile: [], desktop: [], terminal: [] }); } catch (error) { console.error('获取客户端下载失败:', error); } finally { setLoading(false); } }; const getPlatformIcon = (platformCode) => { const code = (platformCode || '').toUpperCase(); // 根据 platform_code 判断图标 if (code.includes('IOS') || code.includes('MAC')) { return ; } else if (code.includes('ANDROID')) { return ; } else if (code.includes('TERM') || code.includes('MCU')) { return ; } else { return ; } }; const getPlatformLabel = (client) => { // 优先使用 dict_data 的中文标签 return client.label_cn || client.platform_code || '未知平台'; }; const formatFileSize = (bytes) => { if (!bytes) return ''; const mb = bytes / (1024 * 1024); return `${mb.toFixed(0)} MB`; }; if (loading) { return (

下载客户端

加载中...
); } return (

下载客户端

选择适合您设备的版本

{/* 移动端 */} {clients.mobile && clients.mobile.length > 0 && ( )} {/* 桌面端 */} {clients.desktop && clients.desktop.length > 0 && ( )} {/* 专用终端 */} {clients.terminal && clients.terminal.length > 0 && ( )}
{!clients.mobile?.length && !clients.desktop?.length && !clients.terminal?.length && (
暂无可用的客户端下载
)}
); }; export default ClientDownloads;