import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import KnowledgeCard from './KnowledgeCard'; import { useDispatch } from 'react-redux'; import { showNotification } from '../../store/notification.slice'; import SvgIcon from '../../components/SvgIcon'; export default function KnowledgeBase() { const dispatch = useDispatch(); const navigate = useNavigate(); const [showCreateModal, setShowCreateModal] = useState(false); const [newKnowledgeBase, setNewKnowledgeBase] = useState({ title: '', description: '', }); const knowledgeList = [ { id: '1', title: '产品开发知识库', description: '产品开发流程及规范说明文档', documents: 24, date: '2025-02-15', access: 'full', }, { id: '2', title: '市场分析知识库', description: '2025年Q1市场分析总结', documents: 12, date: '2025-02-10', access: 'read', }, { id: '3', title: '财务知识库', description: '月度财务分析报告', documents: 8, date: '2025-02-01', access: 'none', }, ]; const handleInputChange = (e) => { const { name, value } = e.target; setNewKnowledgeBase((prev) => ({ ...prev, [name]: value, })); }; const handleCreateKnowledgeBase = () => { // Here you would typically call an API to create the knowledge base if (!newKnowledgeBase.title.trim()) { dispatch( showNotification({ message: '请输入知识库名称', type: 'error', }) ); return; } // For now, just show a success notification dispatch( showNotification({ message: '知识库创建成功', type: 'success', }) ); // In a real application, you would get the ID from the API response // For now, we'll generate a mock ID const newId = Date.now().toString(); // Reset form and close modal setNewKnowledgeBase({ title: '', description: '' }); setShowCreateModal(false); // Navigate to the newly created knowledge base with datasets tab navigate(`/knowledge-base/${newId}/datasets`); }; const handleCardClick = (id) => { navigate(`/knowledge-base/${id}/datasets`); }; return (