gerson
2024-06-30 2a2c1177eef03dc2387950c59596704a0390622e
src/layout/component/sidebar/waterLeftAside/asideNew.vue
@@ -35,7 +35,7 @@
               @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>
@@ -56,7 +56,8 @@
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: [
@@ -101,9 +102,13 @@
   }
};
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',
   };
@@ -134,13 +139,22 @@
   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>