import { Template } from "interface/template"; import { Container, Heading, Text, Box, Flex, Table, Button, TextField, ScrollArea, Dialog, IconButton, } from "@radix-ui/themes"; import { PlusIcon, MagnifyingGlassIcon, Pencil1Icon, TrashIcon, ChevronRightIcon, } from "@radix-ui/react-icons"; import { useState } from "react"; import type { Category } from "interface/fields"; // 模拟分类数据 const mockCategories: (Category & { id: number; count: number })[] = [ { id: 1, name: "前端开发", parentId: undefined, count: 15, }, { id: 2, name: "React", parentId: "1", count: 8, }, { id: 3, name: "Vue", parentId: "1", count: 5, }, { id: 4, name: "后端开发", parentId: undefined, count: 12, }, { id: 5, name: "Node.js", parentId: "4", count: 6, }, ]; export default new Template({}, ({ http, args }) => { const [searchTerm, setSearchTerm] = useState(""); const [isAddDialogOpen, setIsAddDialogOpen] = useState(false); const [newCategoryName, setNewCategoryName] = useState(""); const [selectedParentId, setSelectedParentId] = useState< string | undefined >(); return ( {/* 页面标题和操作栏 */} 分类管理 共 {mockCategories.length} 个分类 {/* 搜索栏 */} ) => setSearchTerm(e.target.value) } > {/* 分类列表 */} 分类名称 文章数量 父分类 操作 {mockCategories.map((category) => ( {category.parentId && ( )} {category.name} {category.count} 篇 {category.parentId ? mockCategories.find( (c) => c.id.toString() === category.parentId, )?.name : "-"} ))} {/* 新建分类对话框 */} 新建分类 创建一个新的文章分类 分类名称 ) => setNewCategoryName(e.target.value) } /> 父分类 ); });