yangyin
2024-11-08 b5e920831f3e2ea94c809b0dd99f08c16d9feceb
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 {