From c56ba92667b2b5dded272fb60ad0c2af4983cd43 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期三, 05 三月 2025 17:09:55 +0800 Subject: [PATCH] 修改意见 --- src/components/chat/hooks/useLoadData.ts | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/components/chat/hooks/useLoadData.ts b/src/components/chat/hooks/useLoadData.ts index ce793eb..11b731c 100644 --- a/src/components/chat/hooks/useLoadData.ts +++ b/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, }; }; -- Gitblit v1.9.3