wujingjing
2024-11-08 57817b07cb31a3dd499d37ba3645fffb85ed2fd0
src/components/chat/Chat.vue
@@ -123,7 +123,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 right-0 mr-4 space-x-2"
                           >
                              <el-tooltip effect="dark" content="复制" placement="top">
@@ -153,7 +153,7 @@
                              </el-tooltip>
                           </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
@@ -242,7 +242,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"
@@ -256,8 +256,7 @@
               :setCommonQuestionInfo="setCommonQuestionInfo"
            ></PlayBar>
         </div>
         <div class="sticky bottom-0 w-full p-6 bg-[rgb(247,248,250)] flex justify-center" v-if="isShareCheck">
         </div>
         <div class="sticky bottom-0 w-full p-6 bg-[rgb(247,248,250)] flex justify-center" v-if="isShareCheck"></div>
      </div>
      <CustomDrawer v-model:isShow="drawerIsShow" @updateChatInput="updateChatInput" />
   </div>
@@ -270,11 +269,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';
@@ -286,7 +285,7 @@
   activeRoomId,
   activeSampleId,
   activeSectionAId,
   chatDisplayMode,
   isSharePage,
   getRoomConfig,
   roomConfig,
} from '/@/stores/chatRoom';
@@ -294,6 +293,7 @@
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);
@@ -602,7 +602,10 @@
      messageList.value.at(-1).createTime = currentTime;
   }
};
const { loadRangeData, onChatListScroll, moreIsLoading, nextUserMsgEndIndex } = useScrollLoad({
   isSharePage: isSharePage,
   container: chatListDom,
   historyGroupId: currentRouteId,
   messageList,
@@ -611,11 +614,12 @@
const chatListLoading = ref(false);
const { scrollToBottom } = useScrollToBottom({
const { scrollToBottom, scrollToTop } = useScrollToBottom({
   chatListDom: chatListDom,
});
onMounted(async () => {
   messageList.value = [];
   // 加载初始数据
   chatListLoading.value = true;
@@ -626,19 +630,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 ====================== 关联查询 ======================
@@ -749,8 +760,8 @@
   // isShareCheck.value = true;
   const url = await generateShareUrl();
   ElMessage.success('已复制分享链接')
   toClipboard(url)
   ElMessage.success('已复制分享链接');
   toClipboard(url);
};
const shareCheckChange = (isChecked: boolean, item: ChatMessage) => {
@@ -773,15 +784,16 @@
   const res = await shareChatHistoryByPost({
      history_ids: historyIdStr,
      share_days: 1,
   }).finally(()=>{
   }).finally(() => {
      resetShare();
   });
   if(!res.values) return;
   if (!res.values) return;
   const shareId = Object.values(res.values)[0];
   if(!shareId) return;
   return `${shareId}`
   if (!shareId) return;
   const relativeHref = router.resolve(`share?id=${shareId}`).href;
   const shareLink = `${SERVE_URL}${relativeHref}`;
   return shareLink;
};
//#endregion