From 212433a599d85034fe72b34f55c5699f24b20039 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期四, 09 一月 2025 16:22:24 +0800 Subject: [PATCH] esc 退出全屏 --- src/components/chat/Chat.vue | 121 +++++++++++----------------------------- 1 files changed, 34 insertions(+), 87 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 737079c..5a46112 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -13,8 +13,9 @@ :msgList="computedMessageList" :isTalking="isTalking" @shareClick="shareClick" - @setCommonQuestionClick="setCommonQuestionClick" + @setCommonQuestionClick="setCommonPhraseClick" @sendChatMessage="sendChatMessage" + @stopGenClick="stopGenClick" @askMoreClick="askMoreClick" /> <el-empty v-else-if="isSharePage && !chatListLoading" :image-size="200"> @@ -27,16 +28,15 @@ <!-- 杈撳叆鍖哄煙 --> <template #input-area> <PlayBar + ref="playBarRef" v-model:voicePageIsShow="voicePageIsShow" :isTalking="isTalking" :isHome="false" + :msgList="computedMessageList" v-model="messageContent.values" @sendClick="sendClick" - @showUpChatClick="showUpChatClick" @stopGenClick="stopGenClick" - @showDownChatClick="showDownChatClick" :style="{ width: chatWidth }" - :setCommonQuestionInfo="setCommonQuestionInfo" /> </template> @@ -341,14 +341,29 @@ chunkRes.value = '鍒嗘瀽缁撴潫'; } } + const getLastGroup = () => { + const lastGroup = computedMessageList.value.at(-1).stepGroup.at(-1); + return lastGroup; + } + const getLastStepList = () => { + const stepList = getLastGroup()?.value ?? []; + return stepList; + }; + const getLastStepItem = () => { + const stepList = getLastStepList(); + const lastStepItem = stepList.at(-1); + return lastStepItem; + }; + + const checkStepItem = (stepItem) => { + if (!stepItem.subStep) { + stepItem.subStep = []; + } + }; if (chunkRes.mode === 'question') { - const lastGroup = computedMessageList.value.at(-1).stepGroup.at(-1); - const stepList = lastGroup?.value ?? []; - const lastStepItem = stepList.at(-1); - if (!lastStepItem.subStep) { - lastStepItem.subStep = []; - } + const lastStepItem = getLastStepItem(); + checkStepItem(lastStepItem); lastStepItem.subStep.push({ type: chunkRes.value.type, data: chunkRes.value, @@ -356,6 +371,9 @@ scrollToBottom(); return; } + + + // 鏆傛椂涓嶈�冭檻澶氫釜 report鎯呭喌 // if (lastIsResult && chunkRes.mode !== 'finish') { @@ -610,44 +628,8 @@ loadAmisSource(); }); -//#region ====================== 鍏夋爣杈撳叆涓婁笅绠ご鏄剧ず鍘嗗彶娑堟伅 ====================== -const currentIndex = ref(null); -const history_data = computed(() => { - return computedMessageList.value.filter((item) => item.role === RoleEnum.user); -}); -//鏄剧ず涓婁竴鏉℃秷鎭� -const showUpChatClick = () => { - if (computedMessageList.value.length === 0) return; - if (currentIndex.value == 0) { - messageContent.value.values = history_data.value[currentIndex.value].content.values; - return; - } else { - currentIndex.value = (currentIndex.value + history_data.value.length - 1) % history_data.value.length; - } - messageContent.value.values = history_data.value[currentIndex.value].content.values; -}; -//鏄剧ず涓嬩竴鏉℃秷鎭� -const showDownChatClick = () => { - if (computedMessageList.value.length === 0) return; - if (currentIndex.value == history_data.value.length - 1) { - messageContent.value.values = history_data.value[currentIndex.value].content.values; - return; - } - if (currentIndex.value === null) { - currentIndex.value = 0; - } else { - currentIndex.value = (currentIndex.value + 1) % history_data.value.length; - } - messageContent.value.values = history_data.value[currentIndex.value].content.values; -}; -//#endregion -const showAskMore = computed(() => { - if (!computedMessageList.value || computedMessageList.value.length === 0) return false; - const last = computedMessageList.value.at(-1); - const isShow = last?.role === RoleEnum.assistant && last?.content?.values && last.content?.askMoreList?.length > 0; - const result = isShow && !isSharePage.value; - return result; -}); + + const askMoreClick = (item) => { if (!item.question) return; sendChatMessage({ type: AnswerType.Text, values: item.question }); @@ -660,14 +642,11 @@ messageContent.value.values = content; }; //#endregion -//#region ====================== 鐢ㄦ埛璇㈤棶鐨勯棶棰樿缃负甯哥敤璇� ====================== -const setCommonQuestionInfo = ref({}); - +const playBarRef = useCompRef(PlayBar); //鐢ㄦ埛闂璁剧疆涓哄父鐢ㄨ -const setCommonQuestionClick = (item) => { - setCommonQuestionInfo.value = item; +const setCommonPhraseClick = (item) => { + playBarRef.value.addPhrase(item); }; -//#endregion //#region ====================== 鍒嗕韩 ====================== @@ -680,37 +659,5 @@ </script> <style scoped lang="scss"> -pre { - font-family: -apple-system, 'Noto Sans', 'Helvetica Neue', Helvetica, 'Nimbus Sans L', Arial, 'Liberation Sans', 'PingFang SC', - 'Hiragino Sans GB', 'Noto Sans CJK SC', 'Source Han Sans SC', 'Source Han Sans CN', 'Microsoft YaHei', 'Wenquanyi Micro Hei', - 'WenQuanYi Zen Hei', 'ST Heiti', SimHei, 'WenQuanYi Zen Hei Sharp', sans-serif; -} - -.more-loading { - :deep(.el-loading-spinner) { - --loading-size: 35px; - margin-top: 0; - .circular { - width: var(--loading-size); - height: var(--loading-size); - } - } -} - -:deep(.el-step__icon.is-text) { - --radius-size: 24px; - width: var(--radius-size); - height: var((--radius-size)); -} - -:deep(.el-step__icon-inner) { - font-size: 16px !important; -} -:deep(.el-step__description) { - min-height: 20px; -} - -:deep(.el-step:last-of-type .el-step__description) { - // display: none; -} +@import './index.scss'; </style> -- Gitblit v1.9.3