Sfoglia il codice sorgente

优化群聊话题侧栏交互

samien 2 mesi fa
parent
commit
23a4a69403
2 ha cambiato i file con 15 aggiunte e 1 eliminazioni
  1. 1 1
      src/client/components/app/types.ts
  2. 14 0
      src/client/views/GroupsView.vue

+ 1 - 1
src/client/components/app/types.ts

@@ -13,5 +13,5 @@ export type SidebarItem = {
   expandable?: boolean
   expandable?: boolean
   expanded?: boolean
   expanded?: boolean
   status?: 'online' | 'working' | 'offline'
   status?: 'online' | 'working' | 'offline'
-  icon?: 'chat' | 'groups' | 'file' | 'image' | 'video' | 'audio' | 'link' | 'artifacts' | 'branch' | 'topic' | 'chevron-left'
+  icon?: 'chat' | 'groups' | 'file' | 'image' | 'video' | 'audio' | 'link' | 'artifacts' | 'branch' | 'topic' | 'chevron-left' | 'plus'
 }
 }

+ 14 - 0
src/client/views/GroupsView.vue

@@ -61,6 +61,7 @@ const sidebarSubtitle = computed(() => topicListRoom.value
   ? `${topicListRoom.value.agentCount} 个 Agent`
   ? `${topicListRoom.value.agentCount} 个 Agent`
   : groups.availability === 'available' ? `${activeRooms.value.length} 个活跃房间` : `9119 群聊 ${SUPPORTED_GROUP_PROTOCOL_VERSION_LABEL}`)
   : groups.availability === 'available' ? `${activeRooms.value.length} 个活跃房间` : `9119 群聊 ${SUPPORTED_GROUP_PROTOCOL_VERSION_LABEL}`)
 const GROUP_LIST_BACK_ID = 'group-list'
 const GROUP_LIST_BACK_ID = 'group-list'
+const NEW_TOPIC_ID = 'new-topic'
 function topicSidebarItemId(roomId: string, topicId: string): string { return `topic:${roomId}:${topicId}` }
 function topicSidebarItemId(roomId: string, topicId: string): string { return `topic:${roomId}:${topicId}` }
 function topicFromSidebarItemId(id: string): { roomId: string; topicId: string } | undefined {
 function topicFromSidebarItemId(id: string): { roomId: string; topicId: string } | undefined {
   const match = /^topic:([^:]+):([^:]+)$/.exec(id)
   const match = /^topic:([^:]+):([^:]+)$/.exec(id)
@@ -85,6 +86,11 @@ const sidebarItems = computed<SidebarItem[]>(() => {
     section: room.name,
     section: room.name,
     icon: 'chevron-left',
     icon: 'chevron-left',
     showMore: false,
     showMore: false,
+  }, {
+    id: NEW_TOPIC_ID,
+    title: '新建话题',
+    icon: 'plus',
+    showMore: false,
   }]
   }]
   const roomTopics = groups.topicsForRoom(room.id)
   const roomTopics = groups.topicsForRoom(room.id)
   items.push(...roomTopics.filter(topic => topic.pinned).map(topic => ({
   items.push(...roomTopics.filter(topic => topic.pinned).map(topic => ({
@@ -230,6 +236,10 @@ async function selectSidebarItem(id: string) {
     topicListRoomId.value = null
     topicListRoomId.value = null
     return
     return
   }
   }
+  if (id === NEW_TOPIC_ID && topicListRoom.value) {
+    await startTopic(topicListRoom.value.id)
+    return
+  }
   const topic = topicFromSidebarItemId(id)
   const topic = topicFromSidebarItemId(id)
   if (topic) {
   if (topic) {
     if (topic.roomId !== groups.selectedRoomId) {
     if (topic.roomId !== groups.selectedRoomId) {
@@ -302,6 +312,10 @@ async function startTopicFromRoomAction() {
   if (roomActionMenu.value?.topicId) return
   if (roomActionMenu.value?.topicId) return
   closeRoomActions()
   closeRoomActions()
   if (!roomId) return
   if (!roomId) return
+  await startTopic(roomId)
+}
+
+async function startTopic(roomId: string) {
   try {
   try {
     await groups.selectRoom(roomId)
     await groups.selectRoom(roomId)
     topicListRoomId.value = roomId
     topicListRoomId.value = roomId