fix(web): 左上角自己头像接入真实数据,会话订阅失败不再静默吞错

NavRail 的自己头像此前是硬编码的"我"字,AppShell 从没往下传过真实的
user_id/nickname/avatar_file_id,所以无论是谁登录、有没有上传头像都不会变;
现在改为拉取 /v1/im/me 并用 Avatar 组件渲染,和设置页/联系人等处一致。

ConversationView 打开会话失败时原来是 .catch(() => {}) 整个吞掉,用户会看到
空白的消息列表且没有任何提示;由于已读回执只在拿到消息后才会发,未读角标
也会因此永久卡住。现在失败会弹出错误提示,不再静默。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Your Name
2026-09-15 23:28:53 +08:00
co-authored by Claude Sonnet 5
parent d5fc03db0e
commit 70cc977e16
3 changed files with 33 additions and 6 deletions
+12 -4
View File
@@ -1,5 +1,6 @@
import { Link, useLocation } from 'react-router-dom';
import { Avatar } from './Avatar';
import { Icon } from './Icon';
interface NavRailItem {
@@ -54,13 +55,20 @@ function NavRailButton({ item }: { item: NavRailItem }) {
);
}
interface NavRailProps {
unreadMessages?: number;
/** The logged-in user's own id/name/avatar (`GET /v1/im/me`) -- drives the rail's top self-tile.
* All optional so the rail still renders (as a letter-tile fallback) before that request settles. */
selfId?: string;
selfName?: string;
selfAvatarFileId?: string;
}
/** Persistent 64px icon rail, visible at >=640px (see App.tsx for the <640 bottom-tab fallback). */
export function NavRail({ selfInitial = '我', unreadMessages = 0 }: { selfInitial?: string; unreadMessages?: number }) {
export function NavRail({ unreadMessages = 0, selfId, selfName, selfAvatarFileId }: NavRailProps) {
return (
<nav className="flex h-full w-16 flex-none flex-col items-center border-r border-[#e6e9ee] bg-surface-rail pb-3 pt-3.5">
<div className="mb-[22px] grid h-[38px] w-[38px] place-items-center rounded-[10px] bg-accent text-base font-semibold text-white">
{selfInitial}
</div>
<Avatar id={selfId || ''} name={selfName} avatarFileId={selfAvatarFileId} className="mb-[22px] h-[38px] w-[38px] rounded-[10px] text-base" />
<div className="flex flex-1 flex-col items-center gap-1.5">
{TOP_ITEMS.map((item) => (
<NavRailButton key={item.to} item={item.to === '/messages' ? { ...item, badge: unreadMessages } : item} />