| | |
| | | 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>; |
| | | sendChatMessage: any; |
| | | displayMessageList: ComputedRef<ChatMessage[]>; |
| | | }; |
| | | |
| | | export const useAssistantContentOpt = (option: AssistantContentOptOption) => { |
| | | const { forbidScroll, sendChatMessage, displayMessageList } = option; |
| | | const { sendChatMessage, displayMessageList } = option; |
| | | const { toClipboard } = useClipboard(); |
| | | const isNextChat = ref(false); |
| | | const preQuestion = ref(null); |
| | | |
| | | const copyClick = (item) => { |
| | | const type = item.content.type; |
| | |
| | | answer_state: toSetState, |
| | | }); |
| | | item.state = toSetState; |
| | | forbidScroll.value = true; |
| | | nextTick(() => { |
| | | forbidScroll.value = false; |
| | | }); |
| | | |
| | | }; |
| | | |
| | | const unLikeClick = async (item) => { |
| | |
| | | }); |
| | | item.state = toSetState; |
| | | |
| | | forbidScroll.value = true; |
| | | nextTick(() => { |
| | | forbidScroll.value = false; |
| | | }); |
| | | |
| | | }; |
| | | const feedbackPosition = ref({ |
| | | x: 0, |
| | |
| | | }; |
| | | }); |
| | | }; |
| | | 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); |
| | |
| | | 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; |
| | | } |
| | | }; |
| | | |
| | |
| | | feedbackClick, |
| | | askMoreClick, |
| | | fixQuestionClick, |
| | | isNextChat, |
| | | preQuestion, |
| | | showAskMore, |
| | | showFixQuestion, |
| | | }; |