| | |
| | | @click="roomClick(item)" |
| | | > |
| | | <div class="ywicon icon-xiaoxi flex-0 mr-2.5"></div> |
| | | <div class="flex-auto text-ellipsis text-nowrap text-sm group-hover:text-[#0084ff]">chat room</div> |
| | | <div class="flex-auto text-ellipsis text-nowrap text-sm group-hover:text-[#0084ff]">{{ item.title }}</div> |
| | | <div class="text-gray-100 flex items-center space-x-2 ml-1"> |
| | | <div class="ywicon invisible icon-bianji visible group-hover:visible !text-sm"></div> |
| | | |
| | |
| | | import { nextTick, onMounted, reactive, ref } from 'vue'; |
| | | import type { ChatRoomItem } from './types'; |
| | | import router from '/@/router'; |
| | | import { activeRoomId, chatRoomList } from '/@/stores/chatRoom'; |
| | | import { CreateHistoryGroup, GetHistoryGroups } from '/@/api/ai/chat'; |
| | | import { chatRoomList, activeRoomId } from '/@/stores/chatRoom'; |
| | | let state = reactive({ |
| | | searchInput: '', |
| | | selectDateOption: [ |
| | |
| | | } |
| | | }; |
| | | |
| | | const newChatRoomClick = () => { |
| | | const newChatRoomClick = async () => { |
| | | const res = await CreateHistoryGroup({ |
| | | group_title: 'chat room', |
| | | }); |
| | | |
| | | const newRoom = { |
| | | id: new Date().getTime() + '' + Math.floor(Math.random() * 1000), |
| | | id: res.history_group_id, |
| | | isInitial: true, |
| | | title: 'chat room', |
| | | }; |
| | |
| | | chatRoomRef.value.firstElementChild?.scrollIntoView(); |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | if (router.currentRoute.value.name === 'Home') { |
| | | if (!chatRoomList.value || chatRoomList.value.length === 0) { |
| | | newChatRoomClick(); |
| | | } else { |
| | | roomClick(chatRoomList.value[0]); |
| | | } |
| | | onMounted(async () => { |
| | | const res = await GetHistoryGroups(); |
| | | |
| | | const resData = (res?.groups || []) as any[]; |
| | | chatRoomList.value = resData?.map((item) => { |
| | | return { |
| | | id: item.group_id, |
| | | title: item.group_title, |
| | | createTime: item.create_time, |
| | | isInitial: false, |
| | | }; |
| | | }); |
| | | if (!chatRoomList.value || chatRoomList.value.length === 0) { |
| | | newChatRoomClick(); |
| | | } else { |
| | | roomClick(chatRoomList.value[0]); |
| | | } |
| | | }); |
| | | </script> |