| "use client"; | 
|   | 
| import { Dialog, Transition } from '@headlessui/react'; | 
| import { Fragment } from 'react'; | 
| import ReactMarkdown from 'react-markdown'; | 
| import remarkGfm from 'remark-gfm'; | 
| import { motion } from 'framer-motion'; | 
|   | 
| interface DataPreviewDialogProps { | 
|   isOpen: boolean; | 
|   onClose: () => void; | 
|   markdownContent: string; | 
| } | 
|   | 
| export default function DataPreviewDialog({ | 
|   isOpen, | 
|   onClose, | 
|   markdownContent | 
| }: DataPreviewDialogProps) { | 
|   return ( | 
|     <Transition appear show={isOpen} as={Fragment}> | 
|       <Dialog as="div" className="relative z-50" onClose={onClose}> | 
|         <Transition.Child | 
|           as={Fragment} | 
|           enter="ease-out duration-300" | 
|           enterFrom="opacity-0" | 
|           enterTo="opacity-100" | 
|           leave="ease-in duration-200" | 
|           leaveFrom="opacity-100" | 
|           leaveTo="opacity-0" | 
|         > | 
|           <div className="fixed inset-0 bg-black/80 backdrop-blur-sm" /> | 
|         </Transition.Child> | 
|   | 
|         <div className="fixed inset-0 overflow-y-auto"> | 
|           <div className="flex min-h-full items-center justify-center p-4 text-center"> | 
|             <Transition.Child | 
|               as={Fragment} | 
|               enter="ease-out duration-300" | 
|               enterFrom="opacity-0 scale-95" | 
|               enterTo="opacity-100 scale-100" | 
|               leave="ease-in duration-200" | 
|               leaveFrom="opacity-100 scale-100" | 
|               leaveTo="opacity-0 scale-95" | 
|             > | 
|               <Dialog.Panel className="w-[800px] h-[600px] transform overflow-hidden rounded-xl bg-white shadow-[0_0_30px_rgba(0,0,0,0.15)] transition-all flex flex-col"> | 
|                 <div className="flex items-center justify-between p-6 border-b border-gray-200"> | 
|                   <Dialog.Title className="text-xl font-semibold text-gray-800 flex items-center"> | 
|                     演示数据预览 | 
|                     <motion.span  | 
|                       className="ml-2 inline-block w-2 h-2 rounded-full bg-[#6ADBFF]" | 
|                       animate={{  | 
|                         scale: [1, 1.5, 1], | 
|                         opacity: [0.7, 1, 0.7]  | 
|                       }} | 
|                       transition={{  | 
|                         duration: 2, | 
|                         repeat: Infinity, | 
|                         ease: "easeInOut" | 
|                       }} | 
|                     /> | 
|                   </Dialog.Title> | 
|                   <button | 
|                     onClick={onClose} | 
|                     className="text-gray-500 hover:text-gray-700 transition-colors duration-300 cursor-pointer" | 
|                   > | 
|                     <svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | 
|                       <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" /> | 
|                     </svg> | 
|                   </button> | 
|                 </div> | 
|                 <div className="flex-1 overflow-y-auto p-6"> | 
|                   <div className="prose max-w-none"> | 
|                     <ReactMarkdown  | 
|                       remarkPlugins={[remarkGfm]} | 
|                       components={{ | 
|                         h3: ({ node, ...props }) => ( | 
|                           <h3 className="text-lg font-semibold text-gray-800 mt-8 mb-4 pb-2 border-b border-gray-200" {...props} /> | 
|                         ), | 
|                         table: ({ node, ...props }) => ( | 
|                           <div className="overflow-x-auto my-6 rounded-lg border border-gray-200 shadow-sm"> | 
|                             <table className="min-w-full divide-y divide-gray-200" {...props} /> | 
|                           </div> | 
|                         ), | 
|                         thead: ({ node, ...props }) => ( | 
|                           <thead className="bg-gray-50" {...props} /> | 
|                         ), | 
|                         th: ({ node, children, ...props }) => { | 
|                           // 根据表头内容动态调整宽度 | 
|                           let className = "px-4 py-3 text-center text-sm font-semibold text-gray-700"; | 
|                            | 
|                           if (typeof children === 'string') { | 
|                             // 根据表头内容设置合适的宽度类 | 
|                             if (children === '工位' || children === '数量' || children === '库位') { | 
|                               className += " w-[15%]"; | 
|                             } else if (children === '原材料' || children === '原材料需求' || children === '产线名') { | 
|                               className += " w-[20%]"; | 
|                             } else if (children === '原材料消耗速率' || children === '生产的产品') { | 
|                               className += " w-[25%]"; | 
|                             } | 
|                           } | 
|                            | 
|                           return <th className={className} {...props}>{children}</th>; | 
|                         }, | 
|                         td: ({ node, ...props }) => ( | 
|                           <td className="px-4 py-3 text-sm text-gray-600 border-t border-gray-200 text-center whitespace-nowrap" {...props} /> | 
|                         ), | 
|                         tr: ({ node, ...props }) => ( | 
|                           <tr className="hover:bg-gray-50 transition-colors duration-150" {...props} /> | 
|                         ) | 
|                       }} | 
|                     > | 
|                       {markdownContent} | 
|                     </ReactMarkdown> | 
|                   </div> | 
|                 </div> | 
|               </Dialog.Panel> | 
|             </Transition.Child> | 
|           </div> | 
|         </div> | 
|       </Dialog> | 
|     </Transition> | 
|   ); | 
| }  |