gerson
2024-07-07 d5f17f079d4af2a173015dc86a4d6d472731fac6
src/layout/component/sidebar/components/ChatRecord.vue
@@ -74,6 +74,7 @@
import { debounce, getRecentDateRange } from '/@/utils/util';
import moment from 'moment';
import { useSearch } from '/@/hooks/useSearch';
import { gotoRoute } from '/@/utils/route';
const chatRoomRef = ref<HTMLDivElement>(null);
const queryParams = ref({
@@ -82,20 +83,22 @@
const gotoAnswerPage = (room: ChatRoomItem) => {
   if (room.isInitial) {
      router.push({
      gotoRoute({
         name: 'Home',
         query: {
            id: room.id,
         },
      });
   } else {
      router.push({
      gotoRoute({
         name: 'AskAnswer',
         query: {
            id: room.id,
         },
      });
   }
   setTimeout(() => {
      activeRoomId.value = room.id;
   }, 0);
   activeRoomId.value = room.id;
};
const newChatRoomClick = async () => {
@@ -184,14 +187,19 @@
   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: Number(item.chat_count) === 0,
      };
   });
   // 按最晚时间到最早时间
   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 || !chatRoomList.value?.[0].isInitial) {
      newChatRoomClick();
   } else {