parent
a3def0adc4
commit
4441fe1132
@ -0,0 +1,77 @@
|
|||||||
|
import { useState, useEffect } from 'react';
|
||||||
|
|
||||||
|
import Image from 'next/image';
|
||||||
|
import { useShallow } from 'zustand/react/shallow';
|
||||||
|
|
||||||
|
import { Avatar } from '@/components';
|
||||||
|
import useUserStore from '@/store/user';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TDataList {
|
||||||
|
label: string;
|
||||||
|
value: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function UserCard({ className }: Props) {
|
||||||
|
const { userInfo } = useUserStore(
|
||||||
|
useShallow((state) => ({
|
||||||
|
userInfo: state.userInfo,
|
||||||
|
setShowLogin: state.setShowLogin,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
|
const [userDataList, setUserDataList] = useState<TDataList[]>([
|
||||||
|
{ label: '关注', value: userInfo.followCount },
|
||||||
|
{ label: '粉丝', value: userInfo.fansCount },
|
||||||
|
{ label: '评论', value: userInfo.commentReplyCount },
|
||||||
|
{ label: '获赞', value: userInfo.thumbUpCount },
|
||||||
|
]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setUserDataList([
|
||||||
|
{ label: '关注', value: userInfo.followCount },
|
||||||
|
{ label: '粉丝', value: userInfo.fansCount },
|
||||||
|
{ label: '评论', value: userInfo.commentReplyCount },
|
||||||
|
{ label: '获赞', value: userInfo.thumbUpCount },
|
||||||
|
]);
|
||||||
|
}, [userInfo]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`py-[24px] rounded-[12px] border-[1px] border-[#c3c3c3] shadow-md ${className}`}>
|
||||||
|
{/* 头像 & 昵称 & 个签 */}
|
||||||
|
<div className="flex flex-row items-center px-[27px]">
|
||||||
|
<Avatar size={48} src={userInfo.avatar} />
|
||||||
|
<div className="ml-[17px]">
|
||||||
|
<p className="w-[100px] mt-[1px] text-base text-[15px] leading-[21px] text-overflow">{userInfo.nickName}</p>
|
||||||
|
<p className="w-[100px] mt-[3px] text-[rgba(0,0,0,0.4)] text-[12px] leading-[16.8px] text-overflow">
|
||||||
|
{userInfo.signature}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 用户数据 */}
|
||||||
|
<ul className="flex flex-row items-center justify-between mt-[12px] px-[19px]">
|
||||||
|
{userDataList.map((item, index) => (
|
||||||
|
<li key={index} className="flex flex-col justify-around w-[53px] h-[60px] text-center">
|
||||||
|
<div className="text-base text-[15px] leading-[16.3px]">{item.value}</div>
|
||||||
|
<div className="text-[rgba(0,0,0,0.7)] text-[12px] leading-[16.8px]">{item.label}</div>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{/* 按钮 */}
|
||||||
|
<ul className="px-[15px] mt-[6px]">
|
||||||
|
<li className="flex flex-row justify-between items-center w-[238px] h-[49px] px-[15px] rounded-[3px] text-[15px] leading-[21px] hover:bg-[#f2f3f7] cursor-pointer">
|
||||||
|
<span>我的收藏</span>
|
||||||
|
<Image width={24} height={24} src="/img/icon/love.svg" alt="我的收藏" />
|
||||||
|
</li>
|
||||||
|
<li className="flex flex-row items-center w-[238px] h-[49px] px-[15px] rounded-[3px] text-[15px] leading-[21px] hover:bg-[#f2f3f7] cursor-pointer">
|
||||||
|
<span>退出登录</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in new issue