import { useState } from "react"; import { Card, Table, Badge, Button } from "antd"; import { EditOutlined, DeleteOutlined } from "@ant-design/icons"; import { Plus, FileText } from "lucide-react"; import type { Template } from "@/pages/SynthesisTask/synthesis"; import { useNavigate } from "react-router"; import { mockTemplates } from "@/mock/synthesis"; import { SearchControls } from "@/components/SearchControls"; export default function InstructionTemplateTab() { const navigate = useNavigate(); const [searchQuery, setSearchQuery] = useState(""); const [templates, setTemplates] = useState(mockTemplates); const [filterTemplateType, setFilterTemplateType] = useState("all"); // 过滤模板 const filteredTemplates = templates.filter((template) => { const matchesSearch = template.name.toLowerCase().includes(searchQuery.toLowerCase()) || template.description.toLowerCase().includes(searchQuery.toLowerCase()); const matchesType = filterTemplateType === "all" || template.type === filterTemplateType; return matchesSearch && matchesType; }); const getQualityColor = (quality: number) => { if (quality >= 90) return "text-green-600 bg-green-50 border-green-200"; if (quality >= 80) return "text-blue-600 bg-blue-50 border-blue-200"; if (quality >= 70) return "text-yellow-600 bg-yellow-50 border-yellow-200"; return "text-red-600 bg-red-50 border-red-200"; }; // 模板表格列 const templateColumns = [ { title: "模板名称", dataIndex: "name", key: "name", fixed: "left", render: (text: string, template: Template) => (
{template.name}
{template.description}
), }, { title: "类型", dataIndex: "type", key: "type", render: (type: string) => ( {type === "preset" ? "预置" : "自定义"} ), }, { title: "分类", dataIndex: "category", key: "category", render: (category: string) => ( {category} ), }, { title: "变量数量", dataIndex: "variables", key: "variables", render: (variables: string[]) => (
{variables.length}
), }, { title: "使用次数", dataIndex: "usageCount", key: "usageCount", render: (usageCount: number) => (
{usageCount}
), }, { title: "质量评分", dataIndex: "quality", key: "quality", render: (quality: number) => (quality ? `${quality}%` : "-"), }, { title: "最后使用", dataIndex: "lastUsed", key: "lastUsed", render: (lastUsed: string) => (
{lastUsed || "-"}
), }, { title: "操作", key: "actions", fixed: "right", render: (_: any, template: Template) => (
), }, ]; return (
{ setFilterTemplateType(filters.type?.[0] || "all"); }} showFilters showViewToggle={false} /> {/* 模板表格 */}

暂无指令模板

{searchQuery ? "没有找到匹配的模板" : "开始创建您的第一个指令模板"}

{!searchQuery && ( )} ), }} /> ); }