From 84d4c7fd7f489313fb354c7813399994e3b682fa Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期三, 27 十一月 2024 11:56:25 +0800 Subject: [PATCH] 分享页打不开 bug --- src/layout/component/sidebar/components/ChatRecord.vue | 46 +++++++++++----------- src/stores/chatRoom.ts | 36 ------------------ 2 files changed, 23 insertions(+), 59 deletions(-) diff --git a/src/layout/component/sidebar/components/ChatRecord.vue b/src/layout/component/sidebar/components/ChatRecord.vue index bbb7268..6a12559 100644 --- a/src/layout/component/sidebar/components/ChatRecord.vue +++ b/src/layout/component/sidebar/components/ChatRecord.vue @@ -68,10 +68,10 @@ import moment from 'moment'; import { computed, onMounted, ref, watch } from 'vue'; import type { ChatRoomItem } from './types'; -import { DeleteHistoryGroups, setHistoryGroupTitle } from '/@/api/ai/chat'; +import { DeleteHistoryGroups, GetHistoryGroups, setHistoryGroupTitle } from '/@/api/ai/chat'; import { useSearch } from '/@/hooks/useSearch'; import { DateFilter, dateFilterMap } from '/@/model/types/date'; -import { activeRoomId, chatRoomList, gotoAnswerPage, newChatRoomClick } from '/@/stores/chatRoom'; +import { activeChatRoom, activeRoomId, chatRoomList, gotoAnswerPage, newChatRoomClick } from '/@/stores/chatRoom'; import { debounce, getRecentDateRange } from '/@/utils/util'; const chatRoomRef = ref<HTMLDivElement>(null); const queryParams = ref({ @@ -170,27 +170,27 @@ //#endregion onMounted(async () => { - // const res = await GetHistoryGroups(); - // const resData = (res?.groups || []) as any[]; - // // 鎸夋渶鏅氭椂闂村埌鏈�鏃╂椂闂� - // chatRoomList.value = resData - // ?.toSorted((a, b) => { - // return b.create_time.localeCompare(a.create_time); - // }) - // .map((item) => { - // return { - // id: item.group_id, - // title: item.group_title, - // createTime: item.create_time, - // isInitial: Number(item.chat_count) === 0, - // }; - // }); - // if (!chatRoomList.value || chatRoomList.value.length === 0) { - // newChatRoomClick(); - // } else { - // const toClickRoom = activeChatRoom.value ?? chatRoomList.value[0]; - // roomClick(toClickRoom); - // } + const res = await GetHistoryGroups(); + const resData = (res?.groups || []) as any[]; + // 鎸夋渶鏅氭椂闂村埌鏈�鏃╂椂闂� + chatRoomList.value = resData + ?.toSorted((a, b) => { + return b.create_time.localeCompare(a.create_time); + }) + .map((item) => { + return { + id: item.group_id, + title: item.group_title, + createTime: item.create_time, + isInitial: Number(item.chat_count) === 0, + }; + }); + if (!chatRoomList.value || chatRoomList.value.length === 0) { + newChatRoomClick(); + } else { + const toClickRoom = activeChatRoom.value ?? chatRoomList.value[0]; + roomClick(toClickRoom); + } }); </script> <style scoped lang="scss"> diff --git a/src/stores/chatRoom.ts b/src/stores/chatRoom.ts index 67af8b5..8d85350 100644 --- a/src/stores/chatRoom.ts +++ b/src/stores/chatRoom.ts @@ -125,7 +125,6 @@ getSelectListSample(selectSample, userTemplateList); }) .catch((err) => {}); - getHistoryChatRooms(); }; //#endregion @@ -196,38 +195,3 @@ return !this.get()?.web_login; }, }; - -//鍘嗗彶瀵硅瘽 -const getHistoryChatRooms = () => { - return new Promise((resolve, reject) => { - GetHistoryGroups() - .then((res) => { - const resData = (res?.groups || []) as any[]; - chatRoomList.value = resData - .toSorted((a, b) => b.create_time.localeCompare(a.create_time)) - .map((item) => ({ - id: item.group_id, - title: item.group_title, - createTime: item.create_time, - isInitial: Number(item.chat_count) === 0, - })); - - if (!chatRoomList.value || chatRoomList.value.length === 0) { - newChatRoomClick(); - } else { - const toClickRoom = activeChatRoom.value ?? chatRoomList.value[0]; - activeRoomId.value = toClickRoom.id; - gotoAnswerPage(toClickRoom); - } - }) - .then(() => { - resolve(true); - }) - .catch((error) => { - reject(error); - }); - }).catch((error) => { - reject(error); - }); -}; - -- Gitblit v1.9.3