mirror of https://github.com/msgbyte/tailchat
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
673 B
TypeScript
29 lines
673 B
TypeScript
import React from 'react';
|
|
import { Avatar } from 'tailchat-design';
|
|
import { useCachedUserInfo } from 'tailchat-shared';
|
|
|
|
interface UserAvatarProps {
|
|
userId: string;
|
|
className?: string;
|
|
style?: React.CSSProperties;
|
|
size?: 'large' | 'small' | 'default' | number;
|
|
}
|
|
|
|
/**
|
|
* 用户头像组件
|
|
*/
|
|
export const UserAvatar: React.FC<UserAvatarProps> = React.memo((props) => {
|
|
const cachedUserInfo = useCachedUserInfo(props.userId);
|
|
|
|
return (
|
|
<Avatar
|
|
className={props.className}
|
|
style={props.style}
|
|
size={props.size}
|
|
src={cachedUserInfo.avatar}
|
|
name={cachedUserInfo.nickname}
|
|
/>
|
|
);
|
|
});
|
|
UserAvatar.displayName = 'UserAvatar';
|