wujingjing
2024-11-15 a7685b93de4f623e91fce94b4e5f419ca3015c55
src/components/chat/Chat.vue
@@ -118,18 +118,18 @@
                                       <p class="text-red-500">
                                          {{ item.content.errMsg }}
                                       </p>
                                       <div class="mt-5 flex items-center" v-if="showFixQuestion(item)">
                                          <div class="text-gray-600 flex-0">
                                             {{ item.content.origin.err_json.fix_question.title + ':' }}
                                       <div class="mt-3 flex" v-if="showFixQuestion(item)">
                                          <div class="text-gray-600 flex-0 mb-auto py-3">
                                             {{ '猜你想问:' }}
                                          </div>
                                          <div class="ml-1 space-x-2 inline-flex flex-wrap">
                                          <div class="flex-auto space-x-2 space-y-1 inline-flex flex-wrap items-center">
                                             <div
                                                v-for="fixItem in item.content.origin.err_json.fix_question?.values"
                                                v-for="fixItem in item.content.origin?.sample_question"
                                                :key="fixItem"
                                                class="bg-gray-200 p-3 hover:bg-[#c5e0ff] hover:text-[#1c86ff] cursor-pointer rounded-lg"
                                                class="bg-gray-200 p-3 hover:bg-[#c5e0ff] hover:text-[#1c86ff] cursor-pointer rounded-lg first-of-type:ml-2 first-of-type:mt-1"
                                                @click="fixQuestionClick(fixItem, item.content.origin)"
                                             >
                                                {{ fixItem.title }}
                                                {{ fixItem }}
                                             </div>
                                          </div>
                                       </div>
@@ -234,15 +234,12 @@
                     </div>
                  </div>
               </template>
               <el-empty v-else-if="isSharePage && !chatListLoading" :image-size="200"  >
               <el-empty v-else-if="isSharePage && !chatListLoading" :image-size="200">
                  <template #description>
                     <span class="text-[15px]">
                        分享的对话不存在或已失效
                     </span>
                     <span class="text-[15px]"> 分享的对话不存在或已失效 </span>
                  </template>
               </el-empty>
               <div v-if="showAskMore && !isShareCheck" class="ml-4 mt-5 text-sm pb-10">
               <div v-if="showAskMore" class="ml-4 mt-5 text-sm pb-10">
                  <div class="text-gray-600 mb-5">你可以继续问我:</div>
                  <div class="space-y-2 inline-flex flex-col">
                     <div
@@ -281,7 +278,7 @@
import { ElMessage } from 'element-plus';
import _ from 'lodash';
import moment from 'moment';
import { computed, onMounted, ref } from 'vue';
import { computed, onActivated, onMounted, ref } from 'vue';
import useClipboard from 'vue-clipboard3';
import FeedbackPanel from './components/FeedbackPanel.vue';
import { useAssistantContentOpt } from './hooks/useAssistantContentOpt';
@@ -309,6 +306,7 @@
} from '/@/stores/chatRoom';
import { ErrorCode } from '/@/utils/request';
import { toMyFixed } from '/@/utils/util';
import emitter from '/@/utils/mitt';
const chatWidth = '75%';
const voicePageIsShow = ref(false);
let isTalking = ref(false);
@@ -542,7 +540,14 @@
let currentLLMId = null;
const sendChatMessage = async (content: ChatContent = messageContent.value, cb?: any, isCallExtParams?: any) => {
   if (!content?.values || isTalking.value || chatListLoading.value) return;
   if (!content?.values) {
      return;
   }
   if (isTalking.value || chatListLoading.value) {
      ElMessage.warning('ai 正在回复中,请稍后尝试提问');
      return;
   }
   const isNewChat = messageList.value.length === 0;
   if (isNewChat) {
      if (activeSampleId.value) {
@@ -631,16 +636,24 @@
   chatListDom: chatListDom,
});
onActivated(() => {
   emitter.emit('updateHeaderTitle', activeChatRoom.value?.title ?? '');
});
onMounted(async () => {
   messageList.value = [];
   // 加载初始数据
   chatListLoading.value = true;
   await loadRangeData().finally(() => {
      chatListLoading.value = false;
   });
   setTimeout(() => {
      emitter.emit('updateHeaderTitle', activeChatRoom.value?.title ?? '');
   }, 300);
   if (messageList.value.length === 0) {
      messageContent.value = {
         type: AnswerType.Text,
         values: activeChatRoom.value?.title,
@@ -649,10 +662,10 @@
      sendChatMessage();
   } else {
      if (isSharePage.value) {
         setTimeout(() => {
            // 滚动到顶部
            scrollToTop();
         }, 300);
         // setTimeout(() => {
         //    // 滚动到顶部
         //    scrollToTop();
         // }, 300);
      } else {
         setTimeout(() => {
            // 初始状态滚一下