import { Checkbox } from '@nice/ui/components/checkbox'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@nice/ui/components/table'; import { Skeleton } from '@nice/ui/components/skeleton'; import { IconFileText } from '@tabler/icons-react'; import { ArticleRow } from './article-row'; import { ArticleQuickEdit } from './article-quick-edit'; import { useArticlesContext } from './context'; import React from 'react'; interface ArticleTableProps { hasFilters?: boolean; // 是否有筛选条件,用于显示不同的空状态信息 } // 新增骨架屏组件 function ArticleTableSkeleton() { return ( <> {Array.from({ length: 5 }).map((_, i) => (
))} ); } export function ArticleTable({ hasFilters = false }: ArticleTableProps) { const { articles, selectedArticles, quickEditId, handleSelectAll, isLoading } = useArticlesContext(); const isAllSelected = articles.length > 0 && articles.every((article) => selectedArticles.includes(article.id)); return (
文章 状态 分类 作者 数据 日期 操作 {isLoading ? ( ) : articles.length > 0 ? ( articles.map((article) => ( {quickEditId === article.id && } )) ) : (
{hasFilters ? '没有找到符合条件的文章' : '还没有文章'}
{hasFilters ? '请尝试调整搜索条件' : '点击"新建文章"开始创作吧'}
)}
); }