wujingjing
2025-01-16 f1360cc184810c1458af6577b9e43f32aca7b24d
src/components/chat/Chat.vue
@@ -49,7 +49,7 @@
import moment from 'moment';
import { computed, onActivated, onMounted, ref } from 'vue';
import { loadAmisSource } from '../amis/load';
import {   useScrollLoad } from './hooks/useScrollLoad';
import { useScrollLoad } from './hooks/useScrollLoad';
import type { ChatContent } from './model/types';
import { AnswerState, AnswerType, RoleEnum, type ChatMessage } from './model/types';
import { getShareChatJsonByPost, questionStreamByPost } from '/@/api/ai/chat';
@@ -78,7 +78,9 @@
import { useSyncMsg } from './hooks/useSyncMsg';
const containerRef = useCompRef(ChatContainer);
const chatListDom = computed(() => containerRef.value?.chatListDom);
const scrollToBottom = () => {
   containerRef.value?.scrollToBottom();
};
const { loadReplyData, parseContent, parseExtraContent, convertProcessItem, convertProcessToStep, formatShowTimeYear } = useLoadData();
const voicePageIsShow = ref(false);
let isTalking = ref(false);
@@ -402,9 +404,11 @@
      updateLoadIndex();
      userItem.historyId = questionRes?.history_id;
      const current = moment().format('YYYY-MM-DD HH:mm:ss');
      userItem.createTime = current;
      userItem.content.values = questionRes?.question ?? userItem.content.values;
      assistantItem.historyId = questionRes?.history_id;
      const currentTime = formatShowTimeYear(moment().format('YYYY-MM-DD HH:mm:ss'));
      const currentTime = formatShowTimeYear(current);
      assistantItem.createTime = currentTime;
      assistantItem.content = resMsgContent;
      setTimeout(() => {
@@ -418,7 +422,6 @@
   sendChatMessage(messageContent.value);
};
const { loadRangeData, onChatListScroll, moreIsLoading, updateLoadIndex } = useScrollLoad({
   container: chatListDom,
   historyGroupId: currentRouteId,
@@ -428,6 +431,12 @@
useSyncMsg({
   msgList: messageList,
   updateLoadIndex,
   historyGroupId: currentRouteId,
   checkCanSync: (data) => {
      return !isTalking.value && !moreIsLoading.value;
   },
   loadReplyData,
   scrollToBottom,
});
const chatListLoading = ref(true);
@@ -442,9 +451,7 @@
   };
   sendChatMessage();
};
const scrollToBottom = () => {
   containerRef.value?.scrollToBottom();
};
const initHistoryChat = () => {
   // 初始状态滚一下