From 93e3f10e847da2db4490cee84b0efedd3ff7be0a Mon Sep 17 00:00:00 2001 From: mackt <1033530438@qq.com> Date: Sun, 7 Apr 2024 00:08:42 +0800 Subject: [PATCH] update(login): Add request error prompt. --- src/app/mylist/page.tsx | 1 - src/components/Header/UserCard.tsx | 14 +++---- src/components/Login/LoginForm.tsx | 38 +++++++++++++------ .../{Header => Login}/LoginModal.tsx | 14 ++++--- src/components/common/Button.tsx | 3 +- src/components/index.ts | 2 +- src/services/client/user.ts | 2 +- src/store/user.ts | 20 +++++----- src/utils/logout.ts | 2 +- 9 files changed, 56 insertions(+), 40 deletions(-) rename src/components/{Header => Login}/LoginModal.tsx (76%) diff --git a/src/app/mylist/page.tsx b/src/app/mylist/page.tsx index 0358497..b5d38c6 100644 --- a/src/app/mylist/page.tsx +++ b/src/app/mylist/page.tsx @@ -36,7 +36,6 @@ export default function Journal() { // journal: apiGetSongCollect, // }; const result = await apiGetSongCollect({ userId: userInfo?.id, pageNum, pageSize }); - console.log(result.data); if (result.code === 200) setList(result.data.rows); }; diff --git a/src/components/Header/UserCard.tsx b/src/components/Header/UserCard.tsx index d4679a0..61327e4 100644 --- a/src/components/Header/UserCard.tsx +++ b/src/components/Header/UserCard.tsx @@ -5,6 +5,9 @@ import { useRouter } from 'next/navigation'; import { useShallow } from 'zustand/react/shallow'; import { Avatar } from '@/components'; + +import logout from '@/utils/logout'; + import useUserStore from '@/store/user'; interface Props { @@ -19,10 +22,9 @@ interface TDataList { export default function UserCard({ onClose, className }: Props) { const router = useRouter(); - const { userInfo, userLogout } = useUserStore( + const { userInfo } = useUserStore( useShallow((state) => ({ userInfo: state.userInfo, - userLogout: state.userLogout, })), ); @@ -38,12 +40,6 @@ export default function UserCard({ onClose, className }: Props) { onClose(); }; - const handleLogout = async () => { - userLogout(); - router.push('/'); - onClose(); - }; - useEffect(() => { setUserDataList([ { label: '关注', value: userInfo.followCount }, @@ -87,7 +83,7 @@ export default function UserCard({ onClose, className }: Props) {