From b5e920831f3e2ea94c809b0dd99f08c16d9feceb Mon Sep 17 00:00:00 2001 From: yangyin <1850366751@qq.com> Date: 星期五, 08 十一月 2024 14:20:00 +0800 Subject: [PATCH] 修改删除常用语时面板被关闭的问题 --- src/components/chat/hooks/useAssistantContentOpt.ts | 33 ++++++++++++++++++--------------- 1 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/components/chat/hooks/useAssistantContentOpt.ts b/src/components/chat/hooks/useAssistantContentOpt.ts index 50dd174..ca3b327 100644 --- a/src/components/chat/hooks/useAssistantContentOpt.ts +++ b/src/components/chat/hooks/useAssistantContentOpt.ts @@ -6,15 +6,16 @@ import { AnswerState, AnswerType, RoleEnum } from '../model/types'; import { SetHistoryAnswerState } from '/@/api/ai/chat'; import { useClickOther } from '/@/hooks/useClickOther'; +import { onClickOutside } from '@vueuse/core'; +import { chatDisplayMode } from '/@/stores/chatRoom'; export type AssistantContentOptOption = { - forbidScroll: Ref<boolean>; sendChatMessage: any; displayMessageList: ComputedRef<ChatMessage[]>; }; export const useAssistantContentOpt = (option: AssistantContentOptOption) => { - const { forbidScroll, sendChatMessage, displayMessageList } = option; + const { sendChatMessage, displayMessageList } = option; const { toClipboard } = useClipboard(); const preQuestion = ref(null); @@ -37,10 +38,7 @@ answer_state: toSetState, }); item.state = toSetState; - forbidScroll.value = true; - nextTick(() => { - forbidScroll.value = false; - }); + }; const unLikeClick = async (item) => { @@ -51,10 +49,7 @@ }); item.state = toSetState; - forbidScroll.value = true; - nextTick(() => { - forbidScroll.value = false; - }); + }; const feedbackPosition = ref({ x: 0, @@ -79,19 +74,27 @@ }; }); }; - useClickOther( + + onClickOutside( computed(() => feedbackPanelRef.value?.[curFeedbackIndex.value]), - feedbackIsShow, - () => { + (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); const isShow = last?.role === RoleEnum.assistant && last?.content?.values && last.content?.askMoreList?.length > 0; - return isShow; + return isShow && chatDisplayMode.value ==='default' ; }); const showFixQuestion = (item) => { @@ -103,7 +106,7 @@ sendChatMessage({ type: AnswerType.Text, values: item.question }); }; - const fixQuestionClick = (item,originData) => { + const fixQuestionClick = (item, originData) => { if (!item.question) return; preQuestion.value = originData?.question; try { -- Gitblit v1.9.3