From 1622a4d80dd86d0fde35af6908937f9be670fee3 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期二, 17 十二月 2024 10:13:00 +0800
Subject: [PATCH] 停止生成

---
 src/components/chat/components/playBar/phrase/CommonPhrases.vue |   36 ++++++++++++++++++++++++------------
 1 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/src/components/chat/components/playBar/phrase/CommonPhrases.vue b/src/components/chat/components/playBar/phrase/CommonPhrases.vue
index 5ebd163..f650df3 100644
--- a/src/components/chat/components/playBar/phrase/CommonPhrases.vue
+++ b/src/components/chat/components/playBar/phrase/CommonPhrases.vue
@@ -59,7 +59,7 @@
 </template>
 
 <script setup lang="ts">
-import { ElMessageBox } from 'element-plus';
+import { ElMessage, ElMessageBox } from 'element-plus';
 import { computed, onMounted, reactive, ref } from 'vue';
 import { addUserSample, deleteUserSample, listUserSample, updateUserSample } from '/@/api/ai/chat';
 import { activeGroupType, activeRoomId, activeSampleId, setRoomConfig } from '/@/stores/chatRoom';
@@ -118,6 +118,7 @@
 		confirmButtonText: '纭畾',
 		cancelButtonText: '鍙栨秷',
 		dangerouslyUseHTMLString: true,
+		closeOnClickModal: false,
 		type: 'warning',
 	}).then(async () => {
 		const res = await deleteUserSample({
@@ -140,17 +141,21 @@
 			handleClose();
 		}
 	} else {
-		const res = await addUserSample({
+		addCommonPhrasesData();
+	}
+};
+//娣诲姞涓�鏉℃暟鎹簮
+const addCommonPhrasesData = async () => {
+	const res = await addUserSample({
+		question: state.inputCommonPhrases,
+		group_type: activeGroupType.value,
+	});
+	if (res.json_ok) {
+		commonPhrases.value.push({
+			id: res.sample_id,
 			question: state.inputCommonPhrases,
-			group_type: activeGroupType.value,
 		});
-		if (res.json_ok) {
-			commonPhrases.value.push({
-				id: res.sample_id,
-				question: state.inputCommonPhrases,
-			});
-			handleClose();
-		}
+		handleClose();
 	}
 };
 //#endregion
@@ -164,13 +169,20 @@
 	activeSampleId.value = item.id;
 };
 const commonChatByUser = (data) => {
-	commonPhrases.value.push(data);
+	const question = data.question;
+	const isCommon = commonPhrases.value.findIndex((item) => item.question === question) > -1;
+	if (isCommon) {
+		return ElMessage.warning('璇ラ棶棰樺凡瀛樺湪甯哥敤璇腑');
+	} else {
+		state.inputCommonPhrases = question;
+		addCommonPhrasesData();
+	}
 };
 //#endregion
 onMounted(() => {
 	getCommonPhrases();
 });
-defineExpose({ commonChatByUser });
+defineExpose({ commonChatByUser, getCommonPhrases });
 </script>
 <style scoped lang="scss">
 .container {

--
Gitblit v1.9.3