From 6e09e21b98b487621e7f19e1b91012a0e9e617ed Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期五, 21 三月 2025 13:06:26 +0800 Subject: [PATCH] z-index: 1; --- src/components/chat/hooks/useAssistantContentOpt.ts | 66 ++++++++++++++------------------- 1 files changed, 28 insertions(+), 38 deletions(-) diff --git a/src/components/chat/hooks/useAssistantContentOpt.ts b/src/components/chat/hooks/useAssistantContentOpt.ts index 4cba696..37b443a 100644 --- a/src/components/chat/hooks/useAssistantContentOpt.ts +++ b/src/components/chat/hooks/useAssistantContentOpt.ts @@ -1,22 +1,20 @@ import { ElMessage } from 'element-plus'; -import type { ComputedRef, Ref } from 'vue'; +import type { ComputedRef } from 'vue'; import { computed, nextTick, ref } from 'vue'; -import useClipboard from 'vue-clipboard3'; +// import useClipboard from 'vue-clipboard3'; +import { onClickOutside, useClipboard } from '@vueuse/core'; import type { ChatMessage } from '../model/types'; import { AnswerState, AnswerType, RoleEnum } from '../model/types'; import { SetHistoryAnswerState } from '/@/api/ai/chat'; -import { useClickOther } from '/@/hooks/useClickOther'; +import { isSharePage } 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 { toClipboard } = useClipboard(); - const preQuestion = ref(null); + const { sendChatMessage } = option; + const { copy } = useClipboard(); const copyClick = (item) => { const type = item.content.type; @@ -27,7 +25,7 @@ text = item.content.values; } ElMessage.success('澶嶅埗鎴愬姛'); - toClipboard(text); + copy(text); }; const likeClick = async (item) => { @@ -37,10 +35,6 @@ answer_state: toSetState, }); item.state = toSetState; - forbidScroll.value = true; - nextTick(() => { - forbidScroll.value = false; - }); }; const unLikeClick = async (item) => { @@ -50,11 +44,6 @@ answer_state: toSetState, }); item.state = toSetState; - - forbidScroll.value = true; - nextTick(() => { - forbidScroll.value = false; - }); }; const feedbackPosition = ref({ x: 0, @@ -74,28 +63,31 @@ feedbackIsShow.value = true; nextTick(() => { feedbackPosition.value = { - x: -feedbackPanelRef.value[index].$el.clientWidth + offsetX, - y: -feedbackPanelRef.value[index].$el.clientHeight + offsetY, + x: -feedbackPanelRef.value[index]?.$el.clientWidth + offsetX, + y: -feedbackPanelRef.value[index]?.$el.clientHeight + offsetY, }; }); }; - useClickOther( - computed(() => feedbackPanelRef.value[curFeedbackIndex.value]), - feedbackIsShow, - () => { + + onClickOutside( + computed(() => feedbackPanelRef.value?.[curFeedbackIndex.value]), + (e) => { 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; - }); + // useClickOther( + // computed(() => feedbackPanelRef.value?.[curFeedbackIndex.value]), + // feedbackIsShow, + // () => { + // feedbackIsShow.value = false; + // feedbackContent.value = ''; + // } + // ); + const showFixQuestion = (item) => { - const isShow = item?.role === RoleEnum.assistant && item?.content?.values && item.content?.origin?.err_json?.fix_question; + const isShow = item?.role === RoleEnum.assistant && item.content?.origin?.sample_question?.length > 0 && !isSharePage.value; return isShow; }; const askMoreClick = (item) => { @@ -103,16 +95,16 @@ sendChatMessage({ type: AnswerType.Text, values: item.question }); }; - const fixQuestionClick = (item,originData) => { - if (!item.question) return; - preQuestion.value = originData?.question; + const fixQuestionClick = (item, originData) => { + if (!item) return; + // preQuestion.value = originData?.question; try { sendChatMessage({ type: AnswerType.Text, - values: item.question, + values: item, }); } finally { - preQuestion.value = null; + // preQuestion.value = null; } }; @@ -129,8 +121,6 @@ feedbackClick, askMoreClick, fixQuestionClick, - preQuestion, - showAskMore, showFixQuestion, }; }; -- Gitblit v1.9.3