From f7ea0b4ceb05fc15e363d918bff74022efd29d53 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期四, 22 八月 2024 17:36:31 +0800 Subject: [PATCH] onClickOutside --- src/components/chat/hooks/useAssistantContentOpt.ts | 27 ++++++++++++++++++--------- 1 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/components/chat/hooks/useAssistantContentOpt.ts b/src/components/chat/hooks/useAssistantContentOpt.ts index 6141114..a691603 100644 --- a/src/components/chat/hooks/useAssistantContentOpt.ts +++ b/src/components/chat/hooks/useAssistantContentOpt.ts @@ -6,6 +6,7 @@ import { AnswerState, AnswerType, RoleEnum } from '../model/types'; import { SetHistoryAnswerState } from '/@/api/ai/chat'; import { useClickOther } from '/@/hooks/useClickOther'; +import { onClickOutside } from '@vueuse/core'; export type AssistantContentOptOption = { forbidScroll: Ref<boolean>; @@ -16,7 +17,7 @@ export const useAssistantContentOpt = (option: AssistantContentOptOption) => { const { forbidScroll, sendChatMessage, displayMessageList } = option; const { toClipboard } = useClipboard(); - const isNextChat = ref(false); + const preQuestion = ref(null); const copyClick = (item) => { const type = item.content.type; @@ -79,14 +80,22 @@ }; }); }; - useClickOther( - computed(() => feedbackPanelRef.value[curFeedbackIndex.value]), - feedbackIsShow, - () => { + + onClickOutside( + computed(() => feedbackPanelRef.value?.[curFeedbackIndex.value]), + (e) => { feedbackIsShow.value = false; feedbackContent.value = ''; } ); + // useClickOther( + // computed(() => feedbackPanelRef.value?.[curFeedbackIndex.value]), + // feedbackIsShow, + // () => { + // feedbackIsShow.value = false; + // feedbackContent.value = ''; + // } + // ); const showAskMore = computed(() => { if (!displayMessageList.value || displayMessageList.value.length === 0) return false; const last = displayMessageList.value.at(-1); @@ -103,16 +112,16 @@ sendChatMessage({ type: AnswerType.Text, values: item.question }); }; - const fixQuestionClick = (item) => { + const fixQuestionClick = (item, originData) => { if (!item.question) return; - isNextChat.value = true; + preQuestion.value = originData?.question; try { sendChatMessage({ type: AnswerType.Text, values: item.question, }); } finally { - isNextChat.value = false; + preQuestion.value = null; } }; @@ -129,7 +138,7 @@ feedbackClick, askMoreClick, fixQuestionClick, - isNextChat, + preQuestion, showAskMore, showFixQuestion, }; -- Gitblit v1.9.3