ConversationList.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <script setup lang="ts">
  2. import { computed, ref } from 'vue'
  3. import AgentAvatar from '@/components/common/AgentAvatar.vue'
  4. import type { WorkspaceConversation } from '@shared/workspace'
  5. const props = defineProps<{ conversations: WorkspaceConversation[]; selected?: string }>()
  6. defineEmits<{ select: [id: string] }>()
  7. const query = ref(''),
  8. archived = ref(false)
  9. const rows = computed(() =>
  10. props.conversations.filter(
  11. (c) =>
  12. c.archived === archived.value &&
  13. (!query.value || `${c.name} ${c.preview}`.toLowerCase().includes(query.value.toLowerCase())),
  14. ),
  15. )
  16. </script>
  17. <template>
  18. <div class="conversation-list">
  19. <input v-model="query" type="search" placeholder="搜索聊天" aria-label="搜索聊天" />
  20. <label class="archive-filter"><input v-model="archived" type="checkbox" />显示已归档</label>
  21. <button
  22. v-for="c in rows"
  23. :key="c.id"
  24. class="conversation-row"
  25. :class="{ selected: c.id === selected }"
  26. @click="$emit('select', c.id)"
  27. >
  28. <AgentAvatar
  29. :name="c.name"
  30. :avatar="c.avatar"
  31. :state="c.activeRunId ? 'working' : 'idle'"
  32. :size="38"
  33. />
  34. <span class="row-text"
  35. ><strong>{{ c.pinned ? '⌖ ' : '' }}{{ c.name }}</strong
  36. ><small
  37. >{{ c.kind === 'group' ? `${c.memberIds.length} 位成员 · ` : ''
  38. }}{{ c.preview || '开始聊天' }}</small
  39. ></span
  40. >
  41. <span v-if="c.lastSeq > c.readSeq" class="unread" aria-label="未读消息" />
  42. </button>
  43. <p v-if="!rows.length" class="empty">
  44. {{ archived ? '没有已归档聊天' : '创建一个 Agent,开始你的第一段聊天。' }}
  45. </p>
  46. </div>
  47. </template>
  48. <style scoped>
  49. .conversation-list {
  50. padding: 8px;
  51. }
  52. .conversation-list > input {
  53. box-sizing: border-box;
  54. width: 100%;
  55. padding: 10px 12px;
  56. border: 1px solid var(--line);
  57. border-radius: 10px;
  58. background: var(--surface);
  59. color: var(--text-primary);
  60. }
  61. .archive-filter {
  62. display: flex;
  63. gap: 6px;
  64. align-items: center;
  65. font-size: 11px;
  66. color: var(--text-muted);
  67. padding: 10px 3px;
  68. }
  69. .conversation-row {
  70. width: 100%;
  71. display: flex;
  72. align-items: center;
  73. gap: 10px;
  74. border: 0;
  75. border-radius: 12px;
  76. background: transparent;
  77. color: var(--text-primary);
  78. padding: 12px 10px;
  79. text-align: left;
  80. cursor: pointer;
  81. }
  82. .conversation-row:hover,
  83. .conversation-row.selected {
  84. background: var(--surface-soft);
  85. }
  86. .row-text {
  87. display: grid;
  88. gap: 5px;
  89. min-width: 0;
  90. flex: 1;
  91. }
  92. .row-text strong {
  93. font-size: 13px;
  94. }
  95. .row-text small {
  96. font-size: 11px;
  97. color: var(--text-muted);
  98. overflow: hidden;
  99. text-overflow: ellipsis;
  100. white-space: nowrap;
  101. }
  102. .unread {
  103. width: 7px;
  104. height: 7px;
  105. border-radius: 50%;
  106. background: var(--accent, #507f6c);
  107. }
  108. .empty {
  109. padding: 24px 12px;
  110. font-size: 13px;
  111. line-height: 1.8;
  112. color: var(--text-muted);
  113. }
  114. </style>