wujingjing
2025-03-05 c56ba92667b2b5dded272fb60ad0c2af4983cd43
src/components/chat/hooks/useLoadData.ts
@@ -3,7 +3,13 @@
import { AnswerType, MultiChatType, RoleEnum, StepEnum } from '../model/types';
import { GetHistoryAnswer } from '/@/api/ai/chat';
import moment from 'moment';
import type { Attach } from '../components/playBar/hook/useAttach';
import {
   getFileGroupType,
   getFileSuffix,
   getIconByGroupType,
   getIconClassByGroupType,
} from '../components/playBar/hook/useUploadFile';
export const useLoadData = () => {
   const parseExtraContent = (res) => {
      if (!res) return {};
@@ -154,6 +160,36 @@
         history_id: historyId,
      });
   };
   const convertAttach = (userValues: any): Attach[] => {
      const attachList: Attach[] = [];
      if (userValues?.attach_tables) {
         userValues.attach_tables.forEach((item: any) => {
            attachList.push({
               title: item.title,
               type: 'table',
               model: item,
               icon: 'biaoge',
               iconClass: 'ywicon-biaoge text-[#c5e0ff]',
            });
         });
      }
      if (userValues?.attach_files) {
         userValues.attach_files.forEach((item: any) => {
            const suffix = getFileSuffix(item.file_name);
            const groupType = getFileGroupType(suffix);
            attachList.push({
               title: item.file_name,
               type: 'file',
               model: item,
               icon: getIconByGroupType(groupType),
               iconClass: getIconClassByGroupType(groupType),
            });
         });
      }
      return attachList;
   };
   /**
    * 获取用户回复数据,并插入到对话当中去
    */
@@ -183,7 +219,8 @@
         const insertIndex = index + 1 + i;
         const currentUserMsg = tmpMessageList[insertIndex - 1];
         currentUserMsg.content.values = item?.answer?.question ?? currentUserMsg.content.values;
         const attachList = convertAttach(item?.answer);
         currentUserMsg.attachList = attachList;
         const mapUser = userItemIdMap.get(index);
         const historyId = mapUser?.history_id;
@@ -267,6 +304,7 @@
      convertProcessToStep,
      convertProcessItem,
      formatShowTimeYear,
      getStepGroupList
      getStepGroupList,
      convertAttach,
   };
};