From 6beefb9fc01ac24f65e0e9758bce1e977064af0b Mon Sep 17 00:00:00 2001 From: H3CoF6 <1707889225@qq.com> Date: Mon, 16 Mar 2026 07:40:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20sidebar=20=E7=9A=84?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Sidebar.tsx | 44 +++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index e6d0147..6b14cb4 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -6,6 +6,7 @@ import { useChatStore } from '../stores/chatStore' import { useAnalyticsStore } from '../stores/analyticsStore' import * as configService from '../services/config' import { onExportSessionStatus, requestExportSessionStatus } from '../services/exportBridge' +import { UserRound } from 'lucide-react' import './Sidebar.scss' @@ -35,6 +36,7 @@ interface AccountProfilesCache { interface WxidOption { wxid: string modifiedTime: number + nickname?: string displayName?: string avatarUrl?: string } @@ -280,26 +282,28 @@ function Sidebar({ collapsed }: SidebarProps) { const accountsCache = readAccountProfilesCache() console.log('[切换账号] 账号缓存:', accountsCache) - const enrichedWxids = wxids.map(option => { + const enrichedWxids = wxids.map((option: WxidOption) => { const normalizedWxid = normalizeAccountId(option.wxid) const cached = accountsCache[option.wxid] || accountsCache[normalizedWxid] + let displayName = option.nickname || option.wxid + let avatarUrl = option.avatarUrl + if (option.wxid === userProfile.wxid || normalizedWxid === userProfile.wxid) { - return { - ...option, - displayName: userProfile.displayName, - avatarUrl: userProfile.avatarUrl - } + displayName = userProfile.displayName || displayName + avatarUrl = userProfile.avatarUrl || avatarUrl } - if (cached) { - console.log('[切换账号] 使用缓存:', option.wxid, cached) - return { - ...option, - displayName: cached.displayName, - avatarUrl: cached.avatarUrl - } + + else if (cached) { + displayName = cached.displayName || displayName + avatarUrl = cached.avatarUrl || avatarUrl + } + + return { + ...option, + displayName, + avatarUrl } - return { ...option, displayName: option.wxid } }) setWxidOptions(enrichedWxids) @@ -553,11 +557,17 @@ function Sidebar({ collapsed }: SidebarProps) { type="button" >
- {option.avatarUrl ? : {getAvatarLetter(option.displayName || option.wxid)}} + {option.avatarUrl ? ( + + ) : ( +
+ +
+ )}
-
{option.displayName || option.wxid}
-
{option.wxid}
+
{option.displayName}
+ {option.displayName !== option.wxid &&
{option.wxid}
}
{userProfile.wxid === option.wxid && 当前}