import React, { useState } from 'react'; import { Box, Typography, Button, Card, CardContent, Grid, Chip, IconButton, Menu, MenuItem, TextField, InputAdornment, Fab, } from '@mui/material'; import { Search as SearchIcon, Add as AddIcon, MoreVert as MoreVertIcon, Folder as FolderIcon, Description as DocumentIcon, } from '@mui/icons-material'; import { styled } from '@mui/material/styles'; const PageContainer = styled(Box)(({ theme }) => ({ padding: '1.5rem', backgroundColor: '#F8F9FA', minHeight: 'calc(100vh - 60px)', })); const PageHeader = styled(Box)(({ theme }) => ({ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '1.5rem', })); const SearchContainer = styled(Box)(({ theme }) => ({ display: 'flex', gap: '1rem', marginBottom: '1.5rem', })); const KBCard = styled(Card)(({ theme }) => ({ height: '100%', transition: 'all 0.2s ease-in-out', border: '1px solid #E5E5E5', '&:hover': { boxShadow: '0 4px 12px rgba(0,0,0,0.1)', transform: 'translateY(-2px)', }, })); const StatusChip = styled(Chip)<{ status: string }>(({ status, theme }) => ({ fontSize: '0.75rem', height: '24px', backgroundColor: status === 'active' ? '#E8F5E8' : status === 'processing' ? '#FFF3CD' : '#F8D7DA', color: status === 'active' ? '#155724' : status === 'processing' ? '#856404' : '#721C24', })); const StatsBox = styled(Box)(({ theme }) => ({ display: 'flex', justifyContent: 'space-between', marginTop: '1rem', padding: '0.75rem', backgroundColor: '#F8F9FA', borderRadius: '6px', })); const StatItem = styled(Box)(({ theme }) => ({ textAlign: 'center', '& .number': { fontSize: '1.25rem', fontWeight: 600, color: theme.palette.primary.main, }, '& .label': { fontSize: '0.75rem', color: '#666', marginTop: '0.25rem', }, })); const mockKnowledgeBases = [ { id: 1, name: '产品文档库', description: '包含所有产品相关的技术文档和用户手册', status: 'active', documents: 156, size: '2.3 GB', lastUpdated: '2024-01-15', }, { id: 2, name: '客服FAQ', description: '常见问题解答和客服对话记录', status: 'processing', documents: 89, size: '1.1 GB', lastUpdated: '2024-01-14', }, { id: 3, name: '法律合规', description: '法律条文、合规要求和相关政策文档', status: 'active', documents: 234, size: '3.7 GB', lastUpdated: '2024-01-13', }, { id: 4, name: '培训资料', description: '员工培训材料和学习资源', status: 'inactive', documents: 67, size: '890 MB', lastUpdated: '2024-01-10', }, ]; const KnowledgeBaseList: React.FC = () => { const [searchTerm, setSearchTerm] = useState(''); const [anchorEl, setAnchorEl] = useState(null); const [selectedKB, setSelectedKB] = useState(null); const handleMenuClick = (event: React.MouseEvent, kbId: number) => { setAnchorEl(event.currentTarget); setSelectedKB(kbId); }; const handleMenuClose = () => { setAnchorEl(null); setSelectedKB(null); }; const filteredKBs = mockKnowledgeBases.filter(kb => kb.name.toLowerCase().includes(searchTerm.toLowerCase()) || kb.description.toLowerCase().includes(searchTerm.toLowerCase()) ); return ( 知识库管理 setSearchTerm(e.target.value)} InputProps={{ startAdornment: ( ), }} sx={{ width: '400px' }} /> {filteredKBs.map((kb) => ( {kb.name} handleMenuClick(e, kb.id)} > {kb.description}
{kb.documents}
文档数量
{kb.size}
存储大小
最后更新: {kb.lastUpdated}
))}
编辑 查看详情 导出 删除
); }; export default KnowledgeBaseList;