wujingjing
2024-10-11 43521ebfcdd69b6e6efec4dae84959c3d793ab0a
聊天项增加 key
已修改2个文件
14 ■■■■ 文件已修改
src/components/chat/Chat.vue 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/chat/hooks/useScrollLoad.ts 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/chat/Chat.vue
@@ -11,7 +11,7 @@
                        class="group flex px-4 py-6 hover:bg-slate-100 rounded-lg relative"
                        :class="{ 'flex-row-reverse': item.role === RoleEnum.user }"
                        v-for="(item, index) of computedMessageList"
                        :key="index"
                        :key="`${item.historyId}_${item.role}`"
                    >
                        <img
                            class="rounded-full size-12 flex-0"
@@ -328,11 +328,6 @@
let currentLLMId = null;
const getAnswerById = async (historyId: string) => {
    return await GetHistoryAnswer({
        history_id: historyId,
    });
};
const sendChatMessage = async (content: ChatContent = messageContent.value, cb?: any, isCallExtParams?: any) => {
    if (!content?.values || isTalking.value || chatListLoading.value) return;
src/components/chat/hooks/useScrollLoad.ts
@@ -1,11 +1,11 @@
import { Ref, ShallowRef, nextTick, onBeforeUnmount, ref } from 'vue';
import { Ref, ShallowRef, nextTick, onBeforeUnmount, ref, unref } from 'vue';
import { LOAD_CHAT_LIMIT } from '../constants';
import { AnswerType, ChatContent, ChatMessage, RoleEnum } from '../model/types';
import { GetHistoryAnswer, QueryHistoryDetail } from '/@/api/ai/chat';
type UseScrollLoadOption = {
    container: ShallowRef<HTMLDivElement>;
    historyGroupId: string;
    historyGroupId: string | Ref<string>;
    messageList: Ref<ChatMessage[]>;
    parseAnswerContent: (res: any) => ChatContent;
};
@@ -79,7 +79,7 @@
     */
    const loadRangeData = async (lastEnd = nextUserMsgEndIndex.value) => {
        const res = await QueryHistoryDetail({
            history_group_id: historyGroupId,
            history_group_id: unref(historyGroupId),,
            last_end: lastEnd,
            last_count: LOAD_CHAT_LIMIT,
        });
@@ -97,7 +97,6 @@
    //滚动监听
    async function onChatListScroll() {
        if (container.value.scrollTop == 0) {
            console.log('滚动到顶部了');
            // 更多数据正在加载时
            if (moreIsLoading.value) {