From 91fbe6ea41b0451a17aa1f6654faa9806b7f1817 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期二, 12 十一月 2024 16:14:26 +0800 Subject: [PATCH] 猜你想问 --- src/components/chat/hooks/useAssistantContentOpt.ts | 36 +++++++++++++----------------------- 1 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/components/chat/hooks/useAssistantContentOpt.ts b/src/components/chat/hooks/useAssistantContentOpt.ts index a691603..d37a56c 100644 --- a/src/components/chat/hooks/useAssistantContentOpt.ts +++ b/src/components/chat/hooks/useAssistantContentOpt.ts @@ -1,22 +1,21 @@ 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 { onClickOutside } from '@vueuse/core'; +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 { sendChatMessage, displayMessageList } = option; + const { copy } = useClipboard(); const preQuestion = ref(null); const copyClick = (item) => { @@ -28,7 +27,7 @@ text = item.content.values; } ElMessage.success('澶嶅埗鎴愬姛'); - toClipboard(text); + copy(text); }; const likeClick = async (item) => { @@ -38,10 +37,6 @@ answer_state: toSetState, }); item.state = toSetState; - forbidScroll.value = true; - nextTick(() => { - forbidScroll.value = false; - }); }; const unLikeClick = async (item) => { @@ -51,11 +46,6 @@ answer_state: toSetState, }); item.state = toSetState; - - forbidScroll.value = true; - nextTick(() => { - forbidScroll.value = false; - }); }; const feedbackPosition = ref({ x: 0, @@ -100,11 +90,11 @@ 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 && !isSharePage; }); 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; return isShow; }; const askMoreClick = (item) => { @@ -113,15 +103,15 @@ }; const fixQuestionClick = (item, originData) => { - if (!item.question) return; - preQuestion.value = originData?.question; + if (!item) return; + // preQuestion.value = originData?.question; try { sendChatMessage({ type: AnswerType.Text, - values: item.question, + values: item, }); } finally { - preQuestion.value = null; + // preQuestion.value = null; } }; -- Gitblit v1.9.3