wujingjing
2024-07-19 568566f1daac7eb3e9a4780655b2d6c38fddd593
src/components/chat/Chat.vue
@@ -33,20 +33,23 @@
                           >
                              <i class="p-2 ywicon icon-copy cursor-pointer hover:text-[#0284ff] hover:!text-[18px]" @click="copyClick(item)" />
                           </div>
                           <div class="flex items-center justify-center size-[15px]">
                              <i
                                 :class="{ 'text-[#0284ff]': item.state === AnswerState.Like }"
                                 class="p-2 ywicon icon-dianzan cursor-pointer hover:text-[#0284ff] font-medium hover:!text-[18px]"
                                 @click="likeClick(item)"
                              />
                           </div>
                           <div class="flex items-center justify-center size-[15px]">
                              <i
                                 :class="{ 'text-[#0284ff]': item.state === AnswerState.Unlike }"
                                 class="p-2 ywicon icon-buzan cursor-pointer hover:text-[#0284ff] !text-[13px] hover:!text-[15px]"
                                 @click="unLikeClick(item)"
                              />
                           </div>
                           <template v-if="item.content.errCode !== ErrorCode.Message">
                              <div class="flex items-center justify-center size-[15px]">
                                 <i
                                    :class="{ 'text-[#0284ff]': item.state === AnswerState.Like }"
                                    class="p-2 ywicon icon-dianzan cursor-pointer hover:text-[#0284ff] font-medium hover:!text-[18px]"
                                    @click="likeClick(item)"
                                 />
                              </div>
                              <div class="flex items-center justify-center size-[15px]">
                                 <i
                                    :class="{ 'text-[#0284ff]': item.state === AnswerState.Unlike }"
                                    class="p-2 ywicon icon-buzan cursor-pointer hover:text-[#0284ff] !text-[13px] hover:!text-[15px]"
                                    @click="unLikeClick(item)"
                                 />
                              </div>
                           </template>
                           <div class="flex items-center justify-center size-[15px] relative">
                              <i
                                 class="p-2 ywicon icon-wentifankui cursor-pointer hover:text-[#0284ff] !text-[13px] hover:!text-[15px]"
@@ -133,7 +136,7 @@
const chatListDom = ref<HTMLDivElement>();
const messageList = ref<ChatMessage[]>([]);
const computedMessageList = computed(() => {
   return messageList.value.filter((v) => v.role !== RoleEnum.system);
   return messageList.value.filter((v) => v && v.role !== RoleEnum.system);
});
const showAskMore = computed(() => {
@@ -144,6 +147,7 @@
});
const parseContent = (res) => {
   if (!res) return null;
   let content: ChatContent = {
      type: AnswerType.Text,
      values: '解析失败!',
@@ -321,10 +325,10 @@
      assistantItem.historyId = questionRes.history_id;
      appendLastMessageContent(resMsgContent);
   } catch (error: any) {
      appendLastMessageContent({
         type: AnswerType.Text,
         values: '发生错误!',
      });
      // appendLastMessageContent({
      //    type: AnswerType.Text,
      //    values: '发生错误!',
      // });
   } finally {
      isTalking.value = false;
   }
@@ -362,12 +366,18 @@
   resList.map((item, index) => {
      const insertIndex = index + 1 + i;
      messageList.value.splice(insertIndex, 0, {
         historyId: item.answer.history_id,
         role: RoleEnum.assistant,
         content: parseContent(item.answer),
         state: item.answer_state,
      });
      messageList.value.splice(
         insertIndex,
         0,
         item.answer === null
            ? null
            : {
                  historyId: item.answer?.history_id,
                  role: RoleEnum.assistant,
                  content: parseContent(item.answer),
                  state: item.answer_state,
              }
      );
      i++;
   });