import { fetchImagePrimaryColor } from '@/utils/image-helper'; import React, { PropsWithChildren } from 'react'; import { AvatarWithPreview, getTextColorHex } from 'tailchat-design'; import { useAsync, UserBaseInfo } from 'tailchat-shared'; /** * 用户信息容器 */ export const UserProfileContainer: React.FC< PropsWithChildren<{ userInfo: UserBaseInfo }> > = React.memo((props) => { const { userInfo } = props; const { value: bannerColor } = useAsync(async () => { if (!userInfo.avatar) { return getTextColorHex(userInfo.nickname); } const rgba = await fetchImagePrimaryColor(userInfo.avatar); return `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`; }, [userInfo.avatar]); return (
{props.children}
); }); UserProfileContainer.displayName = 'UserProfileContainer';