import React, { useState } from 'react'; import { Modal, Form, Input, message } from 'antd'; const { TextArea } = Input; interface CreateKBDialogProps { open: boolean; onCancel: () => void; onCreate: (name: string, description?: string) => Promise; } const CreateKBDialog: React.FC = ({ open, onCancel, onCreate, }) => { const [form] = Form.useForm(); const [loading, setLoading] = useState(false); const handleOk = async () => { try { const values = await form.validateFields(); setLoading(true); await onCreate(values.name, values.description); message.success('知识库创建成功!'); form.resetFields(); onCancel(); } catch (error: any) { if (error.errorFields) { // 表单验证错误 return; } message.error(error.message || '创建失败'); } finally { setLoading(false); } }; const handleCancel = () => { form.resetFields(); onCancel(); }; return (