|
|
|
@ -1,12 +1,14 @@
|
|
|
|
|
import { useState, useEffect } from 'react';
|
|
|
|
|
|
|
|
|
|
import Image from 'next/image';
|
|
|
|
|
import { useRouter } from 'next/navigation';
|
|
|
|
|
import { useShallow } from 'zustand/react/shallow';
|
|
|
|
|
|
|
|
|
|
import { Avatar } from '@/components';
|
|
|
|
|
import useUserStore from '@/store/user';
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
onClose: () => void;
|
|
|
|
|
className?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -15,7 +17,8 @@ interface TDataList {
|
|
|
|
|
value: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function UserCard({ className }: Props) {
|
|
|
|
|
export default function UserCard({ onClose, className }: Props) {
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const { userInfo, userLogout } = useUserStore(
|
|
|
|
|
useShallow((state) => ({
|
|
|
|
|
userInfo: state.userInfo,
|
|
|
|
@ -30,6 +33,17 @@ export default function UserCard({ className }: Props) {
|
|
|
|
|
{ label: '获赞', value: userInfo.thumbUpCount },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const handleGoMyList = () => {
|
|
|
|
|
router.push('/myList');
|
|
|
|
|
onClose();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleLogout = async () => {
|
|
|
|
|
await userLogout;
|
|
|
|
|
router.push('/');
|
|
|
|
|
onClose();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setUserDataList([
|
|
|
|
|
{ label: '关注', value: userInfo.followCount },
|
|
|
|
@ -64,13 +78,16 @@ export default function UserCard({ className }: Props) {
|
|
|
|
|
|
|
|
|
|
{/* 按钮 */}
|
|
|
|
|
<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">
|
|
|
|
|
<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"
|
|
|
|
|
onClick={handleGoMyList}
|
|
|
|
|
>
|
|
|
|
|
<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"
|
|
|
|
|
onClick={userLogout}
|
|
|
|
|
onClick={handleLogout}
|
|
|
|
|
>
|
|
|
|
|
<span>退出登录</span>
|
|
|
|
|
</li>
|
|
|
|
|