From 7866aa30bd13dab1fc0662e1baf6675d0dc1b282 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期三, 02 四月 2025 15:42:30 +0800
Subject: [PATCH] 修改意见

---
 src/components/chat/components/playBar/phrase/CommonPhrases.vue |  133 +++++++++++---------------------------------
 1 files changed, 34 insertions(+), 99 deletions(-)

diff --git a/src/components/chat/components/playBar/phrase/CommonPhrases.vue b/src/components/chat/components/playBar/phrase/CommonPhrases.vue
index f650df3..61bde4d 100644
--- a/src/components/chat/components/playBar/phrase/CommonPhrases.vue
+++ b/src/components/chat/components/playBar/phrase/CommonPhrases.vue
@@ -1,5 +1,5 @@
 <template>
-	<div class="container" :class="isHome ? 'top-[100%] mt-[8px]' : 'bottom-[100%] mb-[8px]'">
+	<div ref="commonPhrasesRef" class="container" :class="isHome ? 'top-[100%] mt-[8px]' : 'bottom-[100%] mb-[8px]'">
 		<div class="container_header">
 			<div class="question">甯哥敤璇�</div>
 			<span class="ywifont ywicon-guanbi text-[15px] cursor-pointer text-[#767a97]" @click="closeCommonPhrases"></span>
@@ -63,6 +63,7 @@
 import { computed, onMounted, reactive, ref } from 'vue';
 import { addUserSample, deleteUserSample, listUserSample, updateUserSample } from '/@/api/ai/chat';
 import { activeGroupType, activeRoomId, activeSampleId, setRoomConfig } from '/@/stores/chatRoom';
+import { onClickOutside } from '@vueuse/core';
 const state = reactive({
 	useCommonPhrasesDialog: false,
 	show_sample_title: false,
@@ -71,7 +72,9 @@
 	sample_id: null,
 });
 const commonPhrases = ref([]);
-const props = defineProps(['isHome']);
+const props = defineProps({
+	isHome: Boolean,
+});
 const isShow = defineModel('isShow', {
 	type: Boolean,
 });
@@ -87,7 +90,7 @@
 };
 //#endregion
 //#region ====================== 鑾峰彇甯哥敤璇� ======================
-const getCommonPhrases = async () => {
+const updatePhrase = async () => {
 	const res = await listUserSample({
 		group_type: activeGroupType.value,
 	});
@@ -161,10 +164,11 @@
 //#endregion
 //#region ====================== 甯哥敤璇埌瀵硅瘽妗� ======================
 const emits = defineEmits<{
-	(event: 'updateCommonChatInput', val): void;
+	(event: 'updateInput', val): void;
 }>();
 const titleClick = (item) => {
-	emits('updateCommonChatInput', item.question);
+	emits('updateInput', item.question);
+	isShow.value = false;
 	setRoomConfig(activeRoomId.value, 'isAnswerByLLM', false);
 	activeSampleId.value = item.id;
 };
@@ -179,102 +183,33 @@
 	}
 };
 //#endregion
-onMounted(() => {
-	getCommonPhrases();
-});
-defineExpose({ commonChatByUser, getCommonPhrases });
-</script>
-<style scoped lang="scss">
-.container {
-	position: absolute;
-	width: 100%;
-	max-height: 40vh;
-	padding: 0 8px 8px;
-	left: 0px;
-	border-radius: 12px;
-	background-color: #ffffff;
-	border: 1px solid #e5e5e5;
-	box-shadow: 0px 8px 25px 0px #0000000d;
-	display: flex;
-	flex-direction: column;
-	z-index: 990;
-	&_header {
-		width: 100%;
-		display: flex;
-		flex-direction: row;
-		justify-content: space-between;
-		align-items: center;
-		padding: 10px 6px;
-		color: #060607;
-		.question {
-			font-size: 14px;
-			color: #060607;
-			font-weight: 600;
-			line-height: 20px;
-			letter-spacing: 0.25px;
-			flex-grow: 1;
-			display: flex;
-		}
-	}
-	&_content {
-		width: 100%;
-		max-height: 35vh;
-		height: fit-content;
-		overflow-y: auto;
-		.set_phrases {
-			outline: none;
-			overflow-y: auto;
-			position: relative;
-			transition: height 0.1s linear;
-			.phase_item {
-				display: flex;
-				flex-direction: row;
-				justify-content: space-between;
-				align-items: center;
-				cursor: pointer;
-				padding: 6px 8px;
-				flex-shrink: 0;
-				background: #fff;
-				border-radius: 8px;
-				width: 100%;
-				&:hover {
-					background: #e5e7ed;
-				}
-				.question {
-					font-size: 14px;
-					color: #8d8e99;
-					font-weight: 400;
-					font-style: normal;
-					white-space: nowrap;
-					text-overflow: ellipsis;
-					overflow: hidden;
-					&:hover {
-						color: #060607;
-					}
-				}
 
-				.content {
-					font-size: 12px;
-					color: #5e6772;
-					font-family: PingFang SC;
-					white-space: nowrap;
-					text-overflow: ellipsis;
-					overflow: hidden;
-				}
-			}
-		}
+const commonPhrasesRef = ref<HTMLDivElement>(null);
+onClickOutside(
+	commonPhrasesRef,
+	() => {
+		isShow.value = false;
+	},
+	{
+		ignore: ['.el-message-box'],
 	}
-	&_add {
-		display: flex;
-		flex-direction: row;
-		align-items: center;
-		cursor: pointer;
-		padding: 6px 8px;
-		background: #fff;
-		border-radius: 8px;
-		&:hover {
-			background: #e5e7ed;
-		}
+);
+
+const addPhrase = (val) =>{
+    if (!props.isHome) {
+		let obj = {
+			id: val?.historyId,
+			question: val?.content.values,
+		};
+		commonChatByUser(obj);
+		isShow.value = true;
 	}
 }
+onMounted(() => {
+	updatePhrase();
+});
+defineExpose({ addPhrase, updatePhrase });
+</script>
+<style scoped lang="scss">
+@use './index.scss';
 </style>

--
Gitblit v1.9.3