ChatHeader.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. "use client";
  2. import { formatConversationTime } from "@/utils/format";
  3. interface ChatHeaderProps {
  4. conversationId: number;
  5. lastSeenAt?: string | null;
  6. unreadCount: number;
  7. onMarkAllRead: () => void;
  8. onRefresh: () => void;
  9. }
  10. export function ChatHeader({
  11. conversationId,
  12. lastSeenAt,
  13. unreadCount,
  14. onMarkAllRead,
  15. onRefresh,
  16. }: ChatHeaderProps) {
  17. return (
  18. <div className="h-16 border-b border-gray-200 flex items-center justify-between px-4 flex-shrink-0">
  19. <div>
  20. <div className="font-semibold text-gray-800">对话 #{conversationId}</div>
  21. <div className="text-xs text-gray-500 mt-0.5">
  22. {lastSeenAt
  23. ? `last seen ${formatConversationTime(lastSeenAt)}`
  24. : "last seen 未知"}
  25. </div>
  26. </div>
  27. <div className="flex items-center gap-2">
  28. <button
  29. className={`w-8 h-8 flex items-center justify-center rounded transition-colors ${
  30. unreadCount > 0
  31. ? "hover:bg-gray-100 text-gray-600"
  32. : "text-gray-300 cursor-not-allowed"
  33. }`}
  34. title="标记全部已读"
  35. onClick={onMarkAllRead}
  36. disabled={unreadCount === 0}
  37. >
  38. <svg
  39. className="w-5 h-5"
  40. fill="none"
  41. stroke="currentColor"
  42. viewBox="0 0 24 24"
  43. >
  44. <path
  45. strokeLinecap="round"
  46. strokeLinejoin="round"
  47. strokeWidth={2}
  48. d="M5 13l4 4L19 7"
  49. />
  50. </svg>
  51. </button>
  52. <button
  53. className="w-8 h-8 flex items-center justify-center hover:bg-gray-100 rounded transition-colors"
  54. title="刷新"
  55. onClick={onRefresh}
  56. >
  57. <svg
  58. className="w-5 h-5 text-gray-600"
  59. fill="none"
  60. stroke="currentColor"
  61. viewBox="0 0 24 24"
  62. >
  63. <path
  64. strokeLinecap="round"
  65. strokeLinejoin="round"
  66. strokeWidth={2}
  67. d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
  68. />
  69. </svg>
  70. </button>
  71. <button
  72. className="w-8 h-8 flex items-center justify-center hover:bg-gray-100 rounded transition-colors"
  73. title="更多选项"
  74. >
  75. <svg
  76. className="w-5 h-5 text-gray-600"
  77. fill="none"
  78. stroke="currentColor"
  79. viewBox="0 0 24 24"
  80. >
  81. <path
  82. strokeLinecap="round"
  83. strokeLinejoin="round"
  84. strokeWidth={2}
  85. d="M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"
  86. />
  87. </svg>
  88. </button>
  89. </div>
  90. </div>
  91. );
  92. }