ConversationList.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use client";
  2. import { ConversationSummary } from "@/features/agent/types";
  3. import { ConversationListItem } from "./ConversationListItem";
  4. interface ConversationListProps {
  5. conversations: ConversationSummary[];
  6. selectedConversationId: number | null;
  7. onSelect: (id: number) => void;
  8. searchQuery: string;
  9. }
  10. export function ConversationList({
  11. conversations,
  12. selectedConversationId,
  13. onSelect,
  14. searchQuery,
  15. }: ConversationListProps) {
  16. if (conversations.length === 0) {
  17. return (
  18. <div className="flex-1 overflow-y-auto scrollbar-auto">
  19. <div className="text-center text-muted-foreground mt-8 text-sm">
  20. {searchQuery ? "未找到匹配的对话" : "暂无对话"}
  21. </div>
  22. </div>
  23. );
  24. }
  25. return (
  26. <div className="flex-1 overflow-y-auto px-2 py-2 scrollbar-auto">
  27. {conversations.map((conversation) => (
  28. <ConversationListItem
  29. key={conversation.id}
  30. conversation={conversation}
  31. selected={selectedConversationId === conversation.id}
  32. onSelect={onSelect}
  33. />
  34. ))}
  35. </div>
  36. );
  37. }