wujingjing
2025-03-05 c56ba92667b2b5dded272fb60ad0c2af4983cd43
src/components/chat/Chat.vue
@@ -82,7 +82,6 @@
import { getCurrentPosition } from '/@/utils/brower';
const containerRef = useCompRef(ChatContainer);
const chatListDom = computed(() => containerRef.value?.chatListDom);
const attachFileList = computed(() => playBarRef.value?.attachFileList ?? []);
const scrollToBottom = () => {
   containerRef.value?.scrollToBottom();
};
@@ -92,6 +91,7 @@
   parseExtraContent,
   convertProcessItem,
   convertProcessToStep,
   convertAttach,
   formatShowTimeYear,
   getStepGroupList,
} = useLoadData();
@@ -142,10 +142,11 @@
      raw_mode: roomConfig.value?.[currentRouteId]?.isAnswerByLLM ?? false,
      ...judgeParams,
   } as any;
   if(businessTableData.value?.length > 0) {
      params.tables = JSON.stringify(businessTableData.value);
   const tableList = attachList.value.filter((item) => item.type === 'table').map((item) => item.model);
   if (tableList?.length > 0) {
      params.tables = JSON.stringify(tableList);
   }
   // if (!position) {
   //    const loadingInstance = ElLoadingService({
   //       text: '获取位置中...',
@@ -171,9 +172,11 @@
      currentSampleId = '';
   }
   const formDataParams = toFormData(params);
   for (const item of attachFileList.value) {
   const fileList = attachList.value.filter((item) => item.type === 'file').map((item) => item.model);
   for (const item of fileList) {
      formDataParams.append('files', item.file);
   }
   // clearAttach();
   let lastTimestamp = new Date().getTime();
   questionRes = {};
   let lastIsResult = false;
@@ -273,9 +276,10 @@
            if (chunkRes.mode === 'conclusion') {
               const lastReport = computedMessageList.value.at(-1)?.content?.values?.at(-1);
               chunkRes.value = '分析结束';
               if (lastReport) {
                  lastReport.conclusion = chunkRes.value;
                  chunkRes.value = '分析结束';
               }
            }
            const getLastGroup = () => {
@@ -348,7 +352,9 @@
               stepList.push(stepItem);
            } else {
               const lastItem = stepList.at(-1);
               lastItem.title += chunkRes.value ?? '';
               if (lastItem) {
                  lastItem.title += chunkRes.value ?? '';
               }
            }
            if (chunkRes.mode === 'begin_stream') {
@@ -384,14 +390,13 @@
   return content;
};
const playBarRef = useCompRef(PlayBar);
const businessTableData = computed(() => playBarRef.value?.businessTableData ?? []);
const clearMessageContent = () =>
   (messageContent.value = {
const attachList = computed(() => playBarRef.value?.attachList ?? []);
const clearMessageContent = () => {
   messageContent.value = {
      type: AnswerType.Text,
      values: '',
   });
   playBarRef.value?.clearFileList();
   playBarRef.value?.clearBusinessTable();
   };
};
let currentSampleId = '';
@@ -418,7 +423,7 @@
const addChatItem = (content: ChatContent) => {
   isTalking.value = true;
   const userItem: ChatMessage = { role: RoleEnum.user, content, isChecked: false } as any;
   const userItem: ChatMessage = { role: RoleEnum.user, content, isChecked: false, attachList: attachList.value } as any;
   const assistantItem: ChatMessage = {
      role: RoleEnum.assistant,
      content: {
@@ -431,6 +436,7 @@
            isShow: true,
         },
      ],
      isStopMsg: false,
      isChecked: false,
   } as any;
@@ -440,6 +446,13 @@
   messageList.value.push(assistantItem);
   scrollToBottom();
   return [userItem, assistantItem];
};
/**
 * 清除附件
 */
const clearAttach = () => {
   playBarRef.value?.clearAttach();
};
const sendChatMessage = async (content: ChatContent = messageContent.value) => {
@@ -544,6 +557,7 @@
         type: AnswerType.Text,
         values: msgValue.question,
      },
      attachList: convertAttach(msgValue),
      isChecked: false,
   };