import React, { useState } from 'react'; import { XMarkIcon, ClipboardIcon, CheckIcon } from '@heroicons/react/24/outline'; import { AiClassificationPreview } from '../types/aiClassification'; import { LoadingSpinner } from './LoadingSpinner'; interface AiClassificationPreviewDialogProps { /** 是否显示对话框 */ isOpen: boolean; /** 预览数据 */ preview: AiClassificationPreview | null; /** 是否正在加载 */ loading: boolean; /** 关闭回调 */ onClose: () => void; } /** * AI分类预览对话框组件 * 遵循前端开发规范的对话框设计,实现提示词实时预览功能 */ export const AiClassificationPreviewDialog: React.FC = ({ isOpen, preview, loading, onClose, }) => { const [copied, setCopied] = useState(false); // 复制到剪贴板 const handleCopy = async () => { if (!preview?.full_prompt) return; try { await navigator.clipboard.writeText(preview.full_prompt); setCopied(true); setTimeout(() => setCopied(false), 2000); } catch (err) { console.error('复制失败:', err); } }; if (!isOpen) return null; return (
{/* 背景遮罩 */}
{/* 对话框 */}
{/* 标题栏 */}

AI分类提示词预览

基于当前激活的分类生成的完整提示词

{/* 内容区域 */}
{loading ? (
正在生成预览...
) : preview ? (
{/* 分类统计 */}

激活的分类数量

{preview.classifications.length}

{/* 分类列表 */}

当前激活的分类

{preview.classifications.map((classification, index) => (
{index + 1}

{classification.name}

{classification.prompt_text}

))}
{/* 完整提示词 */}

完整提示词

                      {preview.full_prompt}
                    

字符数: {preview.full_prompt.length}

{/* 使用说明 */}
使用说明
  • • 此提示词将用于AI视频分类功能
  • • 只有激活状态的分类会包含在提示词中
  • • 分类按照排序顺序显示
  • • 修改分类后需要重新生成预览
) : (

暂无预览数据

请先添加一些AI分类

)}
{/* 按钮栏 */}
); };