HistoryDrawer.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import React from 'react';
  2. import { KnowledgeGroup } from '../types';
  3. import { SearchHistoryList } from './SearchHistoryList';
  4. import { X, History } from 'lucide-react';
  5. interface HistoryDrawerProps {
  6. isOpen: boolean;
  7. onClose: () => void;
  8. groups: KnowledgeGroup[];
  9. onSelectHistory: (historyId: string) => void;
  10. }
  11. export const HistoryDrawer: React.FC<HistoryDrawerProps> = ({
  12. isOpen,
  13. onClose,
  14. groups,
  15. onSelectHistory
  16. }) => {
  17. if (!isOpen) return null;
  18. return (
  19. <div className="fixed inset-0 z-50 overflow-hidden">
  20. <div className="absolute inset-0 bg-black bg-opacity-30 transition-opacity" onClick={onClose} />
  21. <div className="absolute inset-y-0 right-0 max-w-md w-full flex">
  22. <div className="flex-1 flex flex-col bg-white shadow-xl animate-in slide-in-from-right duration-300">
  23. <div className="flex items-center justify-between px-4 py-3 border-b border-gray-200">
  24. <h2 className="text-lg font-medium text-gray-900 flex items-center gap-2">
  25. <History size={20} />
  26. 对话历史
  27. </h2>
  28. <button
  29. onClick={onClose}
  30. className="text-gray-400 hover:text-gray-500 focus:outline-none"
  31. >
  32. <X size={24} />
  33. </button>
  34. </div>
  35. <div className="flex-1 overflow-y-auto p-4">
  36. <SearchHistoryList
  37. groups={groups}
  38. onSelectHistory={onSelectHistory}
  39. />
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. );
  45. };