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" >