wujingjing
2024-11-08 caed4398a7f4e5c244ebbc384a1126bcf61f7f8e
src/components/chat/Chat.vue
@@ -75,7 +75,7 @@
                              </div>
                              <div
                                 v-if="item.role === RoleEnum.user && item.content?.values && chatDisplayMode === 'default' && !isShareCheck"
                                 v-if="item.role === RoleEnum.user && item.content?.values && !isSharePage && !isShareCheck"
                                 class="absolute flex items-center bottom-0 group invisible"
                              >
                                 <div class="bg-[#fff] flex items-center mr-4 space-x-2 flex-nowrap rounded-[6px] py-2 px-2 group-hover:visible">
@@ -155,8 +155,9 @@
                              </template>
                           </div>
                           <!-- 操作 -->
                           </div>
                           <div
                              v-if="item.role === RoleEnum.assistant && item.content?.values && chatDisplayMode === 'default' && !isShareCheck"
                              v-if="item.role === RoleEnum.assistant && item.content?.values && !isSharePage && !isShareCheck"
                              class="absolute flex items-center right-0 mr-4 mt-2 space-x-2"
                           >
                              <div
@@ -245,7 +246,7 @@
         <div
            class="sticky bottom-0 w-full p-6 bg-[rgb(247,248,250)] flex justify-center"
            v-if="chatDisplayMode === 'default' && !isShareCheck"
            v-if="!isSharePage && !isShareCheck"
         >
            <PlayBar
               v-model:voicePageIsShow="voicePageIsShow"
@@ -274,11 +275,11 @@
import FeedbackPanel from './components/FeedbackPanel.vue';
import { useAssistantContentOpt } from './hooks/useAssistantContentOpt';
import { useQueryProcess } from './hooks/useQueryProcess';
import { convertProcessItem, useScrollLoad } from './hooks/useScrollLoad';
import { convertProcessItem, convertProcessToStep, useScrollLoad } from './hooks/useScrollLoad';
import { useScrollToBottom } from './hooks/useScrollToBottom';
import type { ChatContent, StepItem } from './model/types';
import { AnswerState, AnswerType, RoleEnum, answerTypeMapCom, roleImageMap, stepEnumMap, type ChatMessage } from './model/types';
import { extCallQuery, questionStreamByPost, shareChatHistoryByPost } from '/@/api/ai/chat';
import { extCallQuery, getShareChatJsonByPost, questionStreamByPost, shareChatHistoryByPost } from '/@/api/ai/chat';
import PlayBar from '/@/components/chat/components/playBar/PlayBar.vue';
import CustomDrawer from '/@/components/drawer/CustomDrawer.vue';
import { Logger } from '/@/model/logger/Logger';
@@ -290,12 +291,15 @@
   activeRoomId,
   activeSampleId,
   activeSectionAId,
   chatDisplayMode,
   isSharePage,
   getRoomConfig,
   roomConfig,
} from '/@/stores/chatRoom';
import { ErrorCode } from '/@/utils/request';
import { toMyFixed } from '/@/utils/util';
import { ElMessage } from 'element-plus';
import useClipboard from 'vue-clipboard3';
import { toMyFixed, toPercent } from '/@/utils/util';
import { SERVE_URL } from '/@/constants';
const chatWidth = '75%';
const voicePageIsShow = ref(false);
let isTalking = ref(false);
@@ -604,7 +608,10 @@
      messageList.value.at(-1).createTime = currentTime;
   }
};
const { loadRangeData, onChatListScroll, moreIsLoading, nextUserMsgEndIndex } = useScrollLoad({
   isSharePage: isSharePage,
   container: chatListDom,
   historyGroupId: currentRouteId,
   messageList,
@@ -613,11 +620,12 @@
const chatListLoading = ref(false);
const { scrollToBottom } = useScrollToBottom({
const { scrollToBottom, scrollToTop } = useScrollToBottom({
   chatListDom: chatListDom,
});
onMounted(async () => {
   messageList.value = [];
   // 加载初始数据
   chatListLoading.value = true;
@@ -628,19 +636,26 @@
   if (messageList.value.length === 0) {
      messageContent.value = {
         type: AnswerType.Text,
         values: activeChatRoom.value.title,
         values: activeChatRoom.value?.title,
      };
      sendChatMessage();
   } else {
      setTimeout(() => {
         // 初始状态滚一下
         scrollToBottom();
      if (isSharePage.value) {
         setTimeout(() => {
            chatListDom.value.addEventListener('scroll', onChatListScroll);
            // 滚动到顶部
            scrollToTop();
         }, 300);
      }, 300);
      } else {
         setTimeout(() => {
            // 初始状态滚一下
            scrollToBottom();
            setTimeout(() => {
               chatListDom.value.addEventListener('scroll', onChatListScroll);
            }, 300);
         }, 300);
      }
   }
});
//#region ====================== 关联查询 ======================
@@ -782,8 +797,9 @@
   if (!res.values) return;
   const shareId = Object.values(res.values)[0];
   if (!shareId) return;
   return `${shareId}`;
   const relativeHref = router.resolve(`share?id=${shareId}`).href;
   const shareLink = `${SERVE_URL}${relativeHref}`;
   return shareLink;
};
//#endregion