fix(Header): 水合失败

mack-mac
mackt 7 months ago
parent 99b34ffc55
commit 066fe015f9

@ -1,6 +1,5 @@
'use client';
import { parseCookies } from 'nookies';
import { useShallow } from 'zustand/react/shallow';
import HeaderAvatar from './HeaderAvatar';
@ -9,9 +8,9 @@ import { LoginModal } from '@/components';
import useUserStore from '@/store/user';
export default function Auth() {
const { token } = parseCookies();
const { showLogin, setShowLogin } = useUserStore(
const { userInfo, showLogin, setShowLogin } = useUserStore(
useShallow((state) => ({
userInfo: state.userInfo,
showLogin: state.showLogin,
setShowLogin: state.setShowLogin,
})),
@ -19,17 +18,15 @@ export default function Auth() {
return (
<div>
{!!token ? (
{!!userInfo.id ? (
<HeaderAvatar className="ml-[40px]" />
) : (
<div>
<button
className="w-[74px] h-[36px] ml-[40px] border-[#000] border-[1.5px] rounded-[60px] text-[17px] hover:bg-brand hover:border-brand hover:text-[#fff] "
onClick={() => setShowLogin(true)}
>
</button>
</div>
)}
{/* 登录框 */}
{showLogin && <LoginModal />}

Loading…
Cancel
Save