From b63492199ab1fb05d4d04913877dbb6fbf356f90 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 20 May 2026 23:57:18 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(im):=20=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=EF=BC=9A=E5=85=8D=E6=89=93=E6=89=B0=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E6=94=B9=E5=B0=8F=E7=BA=A2=E7=82=B9=E3=80=81=E6=B6=88?= =?UTF-8?q?=E6=81=AF=20Tab=20=E4=BA=8C=E6=AC=A1=E7=82=B9=E5=87=BB=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E5=88=B0=E4=B8=8B=E4=B8=80=E6=9C=AA=E8=AF=BB=E3=80=81?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=B7=A5=E5=85=B7=E6=A0=8F=20hover=20tooltip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/im/home/components/ToolBar.vue | 77 ++++++++++--------- .../conversation/ConversationItem.vue | 9 ++- .../im/home/pages/conversation/index.vue | 50 +++++++++++- src/views/im/home/store/uiStore.ts | 18 ++++- 4 files changed, 113 insertions(+), 41 deletions(-) diff --git a/src/views/im/home/components/ToolBar.vue b/src/views/im/home/components/ToolBar.vue index 122b66e8a..2ef5e24a7 100644 --- a/src/views/im/home/components/ToolBar.vue +++ b/src/views/im/home/components/ToolBar.vue @@ -3,7 +3,9 @@ ToolBar:IM 左侧工具栏 布局:顶部头像 → 中间三 Tab(消息/好友/群聊)→ 底部设置 --> -
+
- -
+ - - - - - - - -
-
+ + + + + + +
- -
- -
-
+
+ +
@@ -64,6 +64,7 @@ import Icon from '@/components/Icon/src/Icon.vue' import { useUserStore } from '@/store/modules/user' import { useConversationStore } from '../store/conversationStore' import { useFriendStore } from '../store/friendStore' +import { useImUiStore } from '../store/uiStore' import UserAvatar from './user/UserAvatar.vue' defineOptions({ name: 'ImToolBar' }) @@ -73,21 +74,25 @@ const router = useRouter() const userStore = useUserStore() const conversationStore = useConversationStore() const friendStore = useFriendStore() +const uiStore = useImUiStore() const totalUnread = computed(() => conversationStore.getTotalUnread) // 消息 Tab 的红点:所有非免打扰会话的未读总和 const unhandledRequestCount = computed(() => friendStore.getUnhandledRequestCount) // 通讯录 Tab 的红点:未处理好友申请数(接收方=我) const tabs = [ - { name: 'ImHomeConversation', label: '消息', icon: 'ep:chat-round' }, - { name: 'ImHomeContact', label: '通讯录', icon: 'mingcute:contacts-line' } + { name: 'ImHomeConversation', icon: 'ep:chat-round' }, + { name: 'ImHomeContact', icon: 'mingcute:contacts-line' } ] // 两个主 Tab;用路由 name 而非 path,避免前缀 / 嵌套调整后失效 /** 当前路由是否命中 Tab:直接比对 route.name */ const isActive = (name: string) => route.name === name -/** 切换 Tab:当前 Tab 已选中时跳过,避免无意义的导航 */ +/** 切换 Tab:当前已选中时,消息 Tab 触发"滚动到下一个未读"(对齐微信 PC),其它 Tab 无动作 */ const goTab = (name: string) => { if (route.name === name) { + if (name === 'ImHomeConversation') { + uiStore.requestNextUnreadJump() + } return } router.push({ name }) diff --git a/src/views/im/home/pages/conversation/components/conversation/ConversationItem.vue b/src/views/im/home/pages/conversation/components/conversation/ConversationItem.vue index 17db6420c..3c95dc3e6 100644 --- a/src/views/im/home/pages/conversation/components/conversation/ConversationItem.vue +++ b/src/views/im/home/pages/conversation/components/conversation/ConversationItem.vue @@ -2,10 +2,11 @@
- +
+ {{ conversation.unreadCount > 99 ? '99+' : conversation.unreadCount }} + +
diff --git a/src/views/im/home/pages/conversation/index.vue b/src/views/im/home/pages/conversation/index.vue index 9c867d3a5..9819069ff 100644 --- a/src/views/im/home/pages/conversation/index.vue +++ b/src/views/im/home/pages/conversation/index.vue @@ -96,10 +96,11 @@ diff --git a/src/views/im/home/store/uiStore.ts b/src/views/im/home/store/uiStore.ts index 509f9060c..1e4be9707 100644 --- a/src/views/im/home/store/uiStore.ts +++ b/src/views/im/home/store/uiStore.ts @@ -1,5 +1,5 @@ import { defineStore, acceptHMRUpdate } from 'pinia' -import { reactive } from 'vue' +import { reactive, ref } from 'vue' import { ImFriendAddSource } from '../../utils/constants' import type { GroupLite, User } from '../types' @@ -116,6 +116,17 @@ export const useImUiStore = defineStore('imUiStore', () => { contextMenu.onSelect = null } + // ==================== 消息 Tab 跳转下一未读 ==================== + // 在 ImHomeConversation 页面再次点击工具栏「消息」时触发; + // 通过递增 nonce 让 conversation/index.vue 的 watch 感知后执行滚动 + 高亮 + + const nextUnreadJumpNonce = ref(0) + + /** 请求滚动到下一个未读会话(含免打扰) */ + function requestNextUnreadJump() { + nextUnreadJumpNonce.value++ + } + return { userInfoCard, openUserInfoCard, @@ -128,7 +139,10 @@ export const useImUiStore = defineStore('imUiStore', () => { contextMenu, openContextMenu, - closeContextMenu + closeContextMenu, + + nextUnreadJumpNonce, + requestNextUnreadJump } })