import { useState } from 'react'; import type { TraderConfigData } from '../types'; // 提取下划线后面的名称部分 function getShortName(fullName: string): string { const parts = fullName.split('_'); return parts.length > 1 ? parts[parts.length - 1] : fullName; } interface TraderConfigViewModalProps { isOpen: boolean; onClose: () => void; traderData?: TraderConfigData | null; } export function TraderConfigViewModal({ isOpen, onClose, traderData }: TraderConfigViewModalProps) { const [copiedField, setCopiedField] = useState(null); if (!isOpen || !traderData) return null; const copyToClipboard = async (text: string, fieldName: string) => { try { await navigator.clipboard.writeText(text); setCopiedField(fieldName); setTimeout(() => setCopiedField(null), 2000); } catch (error) { console.error('Failed to copy:', error); } }; const CopyButton = ({ text, fieldName }: { text: string; fieldName: string }) => ( ); const InfoRow = ({ label, value, copyable = false, fieldName = '' }: { label: string; value: string | number | boolean; copyable?: boolean; fieldName?: string; }) => (
{label}
{typeof value === 'boolean' ? (value ? '是' : '否') : value} {copyable && typeof value === 'string' && value && ( )}
); return (
e.stopPropagation()} > {/* Header */}
👁️

交易员配置

{traderData.trader_name} 的配置信息

{/* Running Status */}
{traderData.is_running ? '●' : '○'} {traderData.is_running ? '运行中' : '已停止'}
{/* Content */}
{/* Basic Info */}

🤖 基础信息

{/* Trading Configuration */}

⚖️ 交易配置

{/* Signal Sources */}

📡 信号源配置

{/* Custom Prompt */}

💬 交易策略提示词

{traderData.custom_prompt && ( )}
{traderData.custom_prompt ? (
{traderData.override_base_prompt ? '自定义提示词' : '附加提示词'}:
{traderData.custom_prompt}
) : (
未设置自定义提示词,使用系统默认策略
)}
{/* Footer */}
); }