diff --git a/frontend-web/src/components/workspace/admin/prompt-templates-page.tsx b/frontend-web/src/components/workspace/admin/prompt-templates-page.tsx deleted file mode 100644 index 139c4f88..00000000 --- a/frontend-web/src/components/workspace/admin/prompt-templates-page.tsx +++ /dev/null @@ -1,258 +0,0 @@ -"use client"; - -import { CheckIcon, Loader2, PencilIcon, PlusIcon, TagIcon, Trash2Icon } from "lucide-react"; -import { useState } from "react"; -import { toast } from "sonner"; - -import { Button } from "@/components/ui/button"; -import { - Dialog, - DialogContent, - DialogFooter, - DialogHeader, - DialogTitle, -} from "@/components/ui/dialog"; -import { Input } from "@/components/ui/input"; -import { Textarea } from "@/components/ui/textarea"; -import { resolveTagColor } from "@/components/workspace/tags/tag-colors"; -import { - usePromptTemplates, - useCreatePromptTemplate, - useDeletePromptTemplate, - useUpdatePromptTemplate, - type PromptTemplate, -} from "@/core/custom-prompts"; -import { useResourceTags, useSetResourceTags, useTags } from "@/core/tags"; -import { cn } from "@/lib/utils"; - -function errMsg(e: unknown): string { - return String(e instanceof Error ? e.message : e); -} - -function TemplateFormDialog({ - open, - onOpenChange, - editing, -}: { - open: boolean; - onOpenChange: (open: boolean) => void; - editing: PromptTemplate | null; -}) { - const createT = useCreatePromptTemplate(); - const updateT = useUpdatePromptTemplate(); - const [title, setTitle] = useState(""); - const [content, setContent] = useState(""); - - const [syncedFor, setSyncedFor] = useState(null); - const syncKey = `${open}:${editing?.id ?? "new"}`; - if (open && syncedFor !== syncKey) { - setTitle(editing?.title ?? ""); - setContent(editing?.content ?? ""); - setSyncedFor(syncKey); - } - if (!open && syncedFor !== null) setSyncedFor(null); - - const pending = createT.isPending || updateT.isPending; - const handleSave = async () => { - if (!content.trim()) return; - try { - if (editing) { - await updateT.mutateAsync({ id: editing.id, input: { title: title.trim(), content } }); - } else { - await createT.mutateAsync({ title: title.trim(), content }); - } - onOpenChange(false); - } catch (e) { - toast.error(errMsg(e)); - } - }; - - return ( - - - - {editing ? "编辑提示词模板" : "新增提示词模板"} - -
-
- - setTitle(e.target.value)} placeholder="如:理赔标准话术" maxLength={255} /> -
-
- -