| | |
| | | import moment from 'moment'; |
| | | import { computed, onMounted, ref, watch } from 'vue'; |
| | | import type { ChatRoomItem } from './types'; |
| | | import { DeleteHistoryGroups, GetHistoryGroups, setHistoryGroupTitle } from '/@/api/ai/chat'; |
| | | import { DeleteHistoryGroups, setHistoryGroupTitle } from '/@/api/ai/chat'; |
| | | import { useSearch } from '/@/hooks/useSearch'; |
| | | import { DateFilter, dateFilterMap } from '/@/model/types/date'; |
| | | import { activeChatRoom, activeRoomId, chatRoomList, gotoAnswerPage, newChatRoomClick } from '/@/stores/chatRoom'; |
| | | import { activeRoomId, chatRoomList, gotoAnswerPage, newChatRoomClick, selectFirstRoom } from '/@/stores/chatRoom'; |
| | | import { debounce, getRecentDateRange } from '/@/utils/util'; |
| | | const chatRoomRef = ref<HTMLDivElement>(null); |
| | | const queryParams = ref({ |
| | |
| | | //#endregion |
| | | |
| | | onMounted(async () => { |
| | | const res = await GetHistoryGroups(); |
| | | const resData = (res?.groups || []) as any[]; |
| | | // 按最晚时间到最早时间 |
| | | chatRoomList.value = resData |
| | | ?.toSorted((a, b) => { |
| | | return b.create_time.localeCompare(a.create_time); |
| | | }) |
| | | .map((item) => { |
| | | return { |
| | | id: item.group_id, |
| | | title: item.group_title, |
| | | createTime: item.create_time, |
| | | isInitial: Number(item.chat_count) === 0, |
| | | }; |
| | | }); |
| | | if (!chatRoomList.value || chatRoomList.value.length === 0) { |
| | | newChatRoomClick(); |
| | | } else { |
| | | const toClickRoom = activeChatRoom.value ?? chatRoomList.value[0]; |
| | | roomClick(toClickRoom); |
| | | } |
| | | selectFirstRoom(); |
| | | }); |
| | | </script> |
| | | <style scoped lang="scss"> |