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 |  164 ++++++++++++++----------------------------------------
 1 files changed, 43 insertions(+), 121 deletions(-)

diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue
index ff4ec3f..5a46112 100644
--- a/src/components/chat/Chat.vue
+++ b/src/components/chat/Chat.vue
@@ -8,39 +8,16 @@
 	>
 		<!-- 娑堟伅鍒楄〃 -->
 		<template #message-list>
-			<template v-if="computedMessageList?.length > 0">
-				<div v-for="(item, msgIndex) of computedMessageList" :key="`${item.historyId}_${item.role}`">
-					<UserMsg
-						:msg="item"
-						@shareClick="shareClick"
-						@setCommonQuestion="setCommonQuestionClick"
-						v-if="item.role === RoleEnum.user"
-					></UserMsg>
-
-					<AssistantMsg
-						v-else
-						:msg="item"
-						:msgList="computedMessageList"
-						:isLast="msgIndex === computedMessageList.length - 1"
-						@sendChatMessage="sendChatMessage"
-						@shareMsg="shareClick"
-						:isTalking="isTalking"
-					/>
-				</div>
-				<div v-if="showAskMore" class="ml-4 mt-5 pb-10">
-					<div class="text-gray-600 mb-5">浣犲彲浠ョ户缁棶鎴戯細</div>
-					<div class="space-y-2 inline-flex flex-col">
-						<div
-							v-for="item in computedMessageList.at(-1).content.askMoreList"
-							:key="item.history_id"
-							class="bg-white p-3 hover:bg-[#c5e0ff] hover:text-[#1c86ff] cursor-pointer rounded-lg"
-							@click="askMoreClick(item)"
-						>
-							{{ item.question }}
-						</div>
-					</div>
-				</div>
-			</template>
+			<MessageList
+				v-if="computedMessageList?.length > 0"
+				:msgList="computedMessageList"
+				:isTalking="isTalking"
+				@shareClick="shareClick"
+				@setCommonQuestionClick="setCommonPhraseClick"
+				@sendChatMessage="sendChatMessage"
+				@stopGenClick="stopGenClick"
+				@askMoreClick="askMoreClick"
+			/>
 			<el-empty v-else-if="isSharePage && !chatListLoading" :image-size="200">
 				<template #description>
 					<span class="text-[15px]">鍒嗕韩鐨勫璇濅笉瀛樺湪鎴栧凡澶辨晥</span>
@@ -51,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>
 
@@ -88,11 +64,10 @@
 import { Logger } from '/@/model/logger/Logger';
 
 import { ElMessage } from 'element-plus';
-import AssistantMsg from './assistant/index.vue';
 import ChatContainer from './components/ChatContainer.vue';
 import ShareLinkDlg from './components/shareLink/index.vue';
-import UserMsg from './user/index.vue';
 import router from '/@/router';
+import MessageList from './messageList/index.vue';
 import {
 	activeChatRoom,
 	activeGroupType,
@@ -366,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,
@@ -381,6 +371,9 @@
 					scrollToBottom();
 					return;
 				}
+				
+				
+
 				// 鏆傛椂涓嶈�冭檻澶氫釜 report鎯呭喌
 
 				// if (lastIsResult && chunkRes.mode !== 'finish') {
@@ -635,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 });
@@ -685,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 ====================== 鍒嗕韩 ======================
 
@@ -705,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