From 3c9dca4d6d09dbf29db217c0e4dcc91e3ef5a13d Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期二, 03 十二月 2024 11:00:35 +0800 Subject: [PATCH] 提问中断 --- src/components/chat/Chat.vue | 37 ++++++++++++++++++++++++++++++------- src/components/chat/hooks/useScrollLoad.ts | 4 ++++ src/components/chat/model/types.ts | 1 + 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 1b7bc16..bb0c56e 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -39,7 +39,9 @@ :style="{ backgroundColor: item.role === RoleEnum.user ? 'rgb(197 224 255)' : 'white' }" :class="{ group: item.role === RoleEnum.user }" > + <!-- #region ====================== 鎰忓浘鍒嗘瀽 ======================--> <div class="flex flex-col" v-if="item?.stepList?.length > 0"> + <!-- #region ====================== 鎰忓浘鍒嗘瀽 ======================--> <div class="flex items-center"> <span class="mr-2">鎰忓浘鍒嗘瀽锛�</span> <div @@ -55,8 +57,9 @@ ></span> </div> </div> + <!-- #endregion --> - <!-- 杩囩▼杈撳嚭 --> + <!-- #region ====================== 杩囩▼杈撳嚭 ======================--> <el-steps v-show="item.stepIsShow" class="mt-3" direction="vertical" :active="activeStep"> <el-step v-for="(subItem, index) in item.stepList" @@ -77,8 +80,11 @@ </template> </el-step> </el-steps> + <!-- #endregion --> </div> + <!-- #endregion --> + <!-- #region ====================== 鐢ㄦ埛鎿嶄綔鎸夐挳 ======================--> <div v-if="item.role === RoleEnum.user && item.content?.values && !isSharePage && !isShareCheck" class="absolute flex items-center bottom-0 group invisible" @@ -114,7 +120,10 @@ </div> </div> + <!-- #endregion --> + <!-- #region ====================== 娑堟伅鍐呭 ======================--> <template v-if="item.content?.values"> + <!-- #region ====================== 鎶ラ敊淇℃伅 ======================--> <div v-if="item.content.errCode === ErrorCode.Message" class="flex-column w-full"> <p class="text-red-500"> {{ item.content.errMsg }} @@ -135,6 +144,8 @@ </div> </div> </div> + <!-- #endregion --> + <!-- #region ====================== 鍥炵瓟缁勪欢 ======================--> <template v-else> <component :conclusion="item.conclusion" @@ -160,9 +171,18 @@ </div> </div> </template> + <!-- #endregion --> </template> + <!-- #endregion --> + <!-- #region ====================== 闄勫姞鍐呭 ======================--> + <!-- #region ====================== 鍋滄 ======================--> + <span v-if="item.isStopMsg && item?.role === RoleEnum.assistant" class="text-gray-400 text-[12px]" + >锛堝凡鍋滄锛�</span + > + <!-- #endregion --> + <!-- #endregion --> </div> - + <!-- #region ====================== ai 娑堟伅鎿嶄綔 ======================--> <div v-if="item.role === RoleEnum.assistant && item.content?.values && !isSharePage && !isShareCheck" class="absolute flex items-center right-0 mr-4 mt-2 space-x-2" @@ -230,6 +250,7 @@ </div> </el-tooltip> </div> + <!-- #endregion --> </div> </div> </div> @@ -289,6 +310,7 @@ </template> <script setup lang="ts"> +import axios, { CancelTokenSource } from 'axios'; import { ElMessage } from 'element-plus'; import { findLast, orderBy } from 'lodash-es'; import moment from 'moment'; @@ -297,7 +319,6 @@ import useClipboard from 'vue-clipboard3'; import FeedbackPanel from './components/FeedbackPanel.vue'; import { useAssistantContentOpt } from './hooks/useAssistantContentOpt'; -import { useQueryProcess } from './hooks/useQueryProcess'; import { convertProcessItem, useScrollLoad } from './hooks/useScrollLoad'; import { useScrollToBottom } from './hooks/useScrollToBottom'; import type { ChatContent, StepItem } from './model/types'; @@ -322,7 +343,6 @@ import emitter from '/@/utils/mitt'; import { ErrorCode } from '/@/utils/request'; import { toMyFixed } from '/@/utils/util'; -import axios, { CancelTokenSource } from 'axios'; const chatWidth = '75%'; const voicePageIsShow = ref(false); let isTalking = ref(false); @@ -401,7 +421,6 @@ content.origin = res; return content; }; -const { clearQueryProcess, process, processId, queryProcess } = useQueryProcess(); //#region ====================== 姝ラ step ====================== const activeStep = ref(-1); @@ -576,8 +595,7 @@ isTalking.value = false; chatListLoading.value = false; resetStep(); - computedMessageList.value.at(-1).stepIsShow = false; - + computedMessageList.value.at(-1).isStopMsg = true; }; const sendChatMessage = async (content: ChatContent = messageContent.value, cb?: any, isCallExtParams?: any) => { @@ -611,6 +629,7 @@ state: AnswerState.Null, stepList: [], stepIsShow: true, + isStopMsg: false, isChecked: false, } as any; // 鍙戦�佸綋鍓� @@ -920,4 +939,8 @@ :deep(.el-step__description) { height: 20px; } + +:deep(.el-step:last-of-type .el-step__description) { + display: none; +} </style> diff --git a/src/components/chat/hooks/useScrollLoad.ts b/src/components/chat/hooks/useScrollLoad.ts index 0309fed..4a8b0ec 100644 --- a/src/components/chat/hooks/useScrollLoad.ts +++ b/src/components/chat/hooks/useScrollLoad.ts @@ -99,6 +99,8 @@ createTime: answerTime, stepList: convertProcessToStep(item?.answer?.exec_process), stepIsShow: false, + isStopMsg: false, + conclusion: item?.answer?.conclusion ?? [], isChecked: false, } @@ -138,6 +140,8 @@ content: parseAnswerContent(msgValue), stepList: convertProcessToStep(msgValue.exec_process), stepIsShow: false, + isStopMsg: false, + conclusion: msgValue.conclusion ?? [], isChecked: false, }; diff --git a/src/components/chat/model/types.ts b/src/components/chat/model/types.ts index f5814e1..3212f7e 100644 --- a/src/components/chat/model/types.ts +++ b/src/components/chat/model/types.ts @@ -58,6 +58,7 @@ createTime?:string, stepList?:StepItem[], stepIsShow?:boolean, + isStopMsg?:boolean, /** @description 鏄惁琚�夋嫨鍒嗕韩 */ isChecked:boolean, conclusion?:any[] -- Gitblit v1.9.3