/** * 智能体选择弹窗 */ import { useEffect, useState } from 'react'; import { PlayCircle, X } from 'lucide-react'; import type { AgentType, EditorialBaseStandard } from '../types'; interface AgentModalProps { visible: boolean; taskCount: number; onClose: () => void; onConfirm: (agents: AgentType[], editorialBaseStandard?: EditorialBaseStandard) => void; defaultEditorialBaseStandard?: EditorialBaseStandard; isSubmitting?: boolean; // 🔒 防止重复提交 } export default function AgentModal({ visible, taskCount, onClose, onConfirm, defaultEditorialBaseStandard = 'zh', isSubmitting = false, }: AgentModalProps) { const [selectedAgents, setSelectedAgents] = useState(['editorial']); const [editorialBaseStandard, setEditorialBaseStandard] = useState(defaultEditorialBaseStandard); useEffect(() => { if (!visible) return; setSelectedAgents(['editorial']); setEditorialBaseStandard(defaultEditorialBaseStandard); }, [visible, defaultEditorialBaseStandard]); const toggleAgent = (agent: AgentType) => { if (selectedAgents.includes(agent)) { // 至少保留一个 if (selectedAgents.length > 1) { setSelectedAgents(selectedAgents.filter(a => a !== agent)); } } else { setSelectedAgents([...selectedAgents, agent]); } }; const handleConfirm = () => { // 只调用onConfirm,让调用方控制关闭时机 onConfirm( selectedAgents, selectedAgents.includes('editorial') ? editorialBaseStandard : undefined ); }; if (!visible) return null; return (
{/* 头部 */}

发起智能审稿

{/* 内容 */}

{taskCount > 1 ? `已选择 ${taskCount} 个稿件,请选择审稿维度:` : '请选择审稿维度:'}

{/* 规范性智能体 */} {selectedAgents.includes('editorial') && (
稿约基线语言
)} {/* 方法学智能体 */} {/* 临床专业评估智能体 */}
{/* 底部按钮 */}
); }