wujingjing
2024-06-28 b89ed80f20f2e07729a68f2c6ed2ca5134332a17
src/components/chat/Chat.vue
@@ -3,19 +3,29 @@
      <div class="h-full flex flex-col items-center overflow-y-auto">
         <div ref="chatListDom" class="h-full">
            <div
               class="group flex px-4 py-3 hover:bg-slate-100 rounded-lg"
               class="group flex px-4 py-4 hover:bg-slate-100 rounded-lg"
               v-for="(item, index) of messageList.filter((v) => v.role !== 'system')"
               :key="index"
            >
               <img class="rounded-full size-10 mr-4" :src="roleImageMap[item.role]" alt="" srcset="" />
               <img class="rounded-full size-12 mr-4" :src="roleImageMap[item.role]" alt="" srcset="" />
               <div class="flex">
                  <div
                     :class="{ 'bg-[#d8d8ff]': item.role !== RoleEnum.user }"
                     class="prose text-sm  rounded-[6px] p-4  leading-relaxed max-w-[100ch]"
                     v-if="item.content"
                     v-html="md.render(item.content)"
                  ></div>
                  <div v-if="item.content">
                     <div
                        :class="{ 'bg-[#d8d8ff]': item.role === RoleEnum.assistant, 'bg-white': item.role === RoleEnum.user }"
                        class="prose text-sm rounded-[6px] p-4 leading-relaxed max-w-[100ch]"
                        v-html="md.render(item.content)"
                     ></div>
                     <div class="">
                        <SvgIcon name="ele-CopyDocument"/>
                        <SvgIcon name="ele-Check"/>
                        <SvgIcon name="ywicon icon-dianzan"/>
                        <SvgIcon name="ywicon icon-buzan"/>
                     </div>
                  </div>
                  <Loding v-else />
               </div>
            </div>
@@ -35,6 +45,7 @@
import { md } from './libs/markdown';
import { RoleEnum, type ChatMessage, roleImageMap } from './types';
import PlayBar from '/@/components/chat/components/playBar/PlayBar.vue';
import router from '/@/router';
let apiKey = '';
let isConfig = ref(false);
@@ -66,6 +77,8 @@
   if (getAPIKey()) {
      switchConfigStatus();
   }
   const inputValue = history.state.inputValue;
});
const sendChatMessage = async (content: string = messageContent.value) => {