categories-table.tsx

categories-table.tsx

基本信息

  • 类型: React 组件
  • 路径: ./src/components/admin/categories-table.tsx

功能描述

管理员分类管理表格组件,支持分类的增删改查操作。提供层级分类展示(父分类和子分类),支持设置分类图标、描述、排序和置顶状态。

导出内容

  • CategoriesTable - 主组件函数
  • Category - 分类数据类型接口

Props

属性类型说明
categoriesCategory[]分类数据数组

类型定义

interface Category {
  id: string;
  name: string;
  slug: string;
  description: string | null;
  icon: string | null;
  order: number;
  pinned: boolean;
  parentId: string | null;
  parent: { id: string; name: string } | null;
  children?: Category[];
  _count: {
    prompts: number;
    children: number;
  };
}

依赖

  • react - useState, useMemo
  • next/navigation - useRouter
  • next-intl - useTranslations
  • @/components/ui/* - Badge, Button, Input, Label, Select, DropdownMenu, Table, Dialog, AlertDialog
  • lucide-react - MoreHorizontal, Plus, Pencil, Trash2, ChevronRight, Pin, PinOff
  • sonner - toast 通知
← 返回目录