From eb0460fbc34fda7906f2949d7dce0f08542e3c8c Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期四, 18 七月 2024 16:52:20 +0800 Subject: [PATCH] 地图展示 --- src/layout/component/sidebar/components/ChatRecord.vue | 40 +++++++++++++++++++++++----------------- 1 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/layout/component/sidebar/components/ChatRecord.vue b/src/layout/component/sidebar/components/ChatRecord.vue index 2d04a0b..39555c6 100644 --- a/src/layout/component/sidebar/components/ChatRecord.vue +++ b/src/layout/component/sidebar/components/ChatRecord.vue @@ -74,8 +74,7 @@ import { debounce, getRecentDateRange } from '/@/utils/util'; import moment from 'moment'; import { useSearch } from '/@/hooks/useSearch'; - - +import { gotoRoute } from '/@/utils/route'; const chatRoomRef = ref<HTMLDivElement>(null); const queryParams = ref({ @@ -84,20 +83,22 @@ const gotoAnswerPage = (room: ChatRoomItem) => { if (room.isInitial) { - router.push({ + gotoRoute({ name: 'Home', + query: { + id: room.id, + }, }); } else { - router.push({ + gotoRoute({ name: 'AskAnswer', query: { id: room.id, }, }); } - setTimeout(() => { - activeRoomId.value = room.id; - }, 0); + + activeRoomId.value = room.id; }; const newChatRoomClick = async () => { @@ -170,7 +171,7 @@ //#endregion //#region ====================== 鎼滅储鑱婂ぉ瀹� ====================== -const { query,queryData } = useSearch(filteredChatRoomList, queryParams); +const { query, queryData } = useSearch(filteredChatRoomList, queryParams); const debounceQuery = debounce(query); @@ -186,15 +187,20 @@ const res = await GetHistoryGroups(); const resData = (res?.groups || []) as any[]; - chatRoomList.value = resData?.map((item) => { - return { - id: item.group_id, - title: item.group_title, - createTime: item.create_time, - isInitial: false, - }; - }); - if (!chatRoomList.value || chatRoomList.value.length === 0) { + // 鎸夋渶鏅氭椂闂村埌鏈�鏃╂椂闂� + 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 || !chatRoomList.value?.[0].isInitial) { newChatRoomClick(); } else { roomClick(chatRoomList.value[0]); -- Gitblit v1.9.3