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