From 94ef796940807e666b0d82f0ef57b42a3e3b83a9 Mon Sep 17 00:00:00 2001 From: yangyin <1850366751@qq.com> Date: 星期二, 05 十一月 2024 11:03:57 +0800 Subject: [PATCH] 切换场景显示不同的常用语 --- src/components/chat/components/playBar/PlayBar.vue | 3 +-- src/components/chat/components/playBar/phrase/CommonPhrases.vue | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/components/chat/components/playBar/PlayBar.vue b/src/components/chat/components/playBar/PlayBar.vue index 38f36f7..e5749f8 100644 --- a/src/components/chat/components/playBar/PlayBar.vue +++ b/src/components/chat/components/playBar/PlayBar.vue @@ -438,11 +438,10 @@ //#region ====================== 褰撳墠搴旂敤鍦烘櫙 ====================== const currentGroupTypeIsShow = computed(() => !!activeGroupType.value); - const groupTypeClick = (item) => { activeGroupType.value = item; - inputRef.value.focus(); + commonPhrasesRef.value.getCommonPhrases(); }; // 鍏抽棴褰撳墠 groupType 闈㈡澘 diff --git a/src/components/chat/components/playBar/phrase/CommonPhrases.vue b/src/components/chat/components/playBar/phrase/CommonPhrases.vue index 5ebd163..ec1735c 100644 --- a/src/components/chat/components/playBar/phrase/CommonPhrases.vue +++ b/src/components/chat/components/playBar/phrase/CommonPhrases.vue @@ -140,17 +140,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 +168,14 @@ activeSampleId.value = item.id; }; const commonChatByUser = (data) => { - commonPhrases.value.push(data); + state.inputCommonPhrases = data.question; + addCommonPhrasesData(); }; //#endregion onMounted(() => { getCommonPhrases(); }); -defineExpose({ commonChatByUser }); +defineExpose({ commonChatByUser,getCommonPhrases }); </script> <style scoped lang="scss"> .container { -- Gitblit v1.9.3