feat: 每次进入请求用户信息

feature/artists
mackt 7 months ago
parent 705f02f7ae
commit 709fb35b03

@ -3,7 +3,7 @@ import Script from 'next/script';
import { Toaster } from '@/components/ui/toaster';
import { Header, Footer, PlayerBar, ScrollTopButton } from '@/components';
import { Header, App, Footer, PlayerBar, ScrollTopButton } from '@/components';
import './globals.css';
@ -31,6 +31,7 @@ export default function RootLayout({ children }: Readonly<{ children: React.Reac
return (
<html lang="zn-ch" className="relative">
<body>
<App />
<Header className="absolute top-0" />
<div>{children}</div>
<Footer />

@ -0,0 +1,21 @@
'use client';
import { useEffect } from 'react';
import { useShallow } from 'zustand/react/shallow';
import { useUserStore } from '@/store';
export default function APP() {
const { getUserInfo } = useUserStore(
useShallow((state) => ({
getUserInfo: state.getUserInfo,
})),
);
useEffect(() => {
getUserInfo();
}, []);
return <div></div>;
}

@ -13,8 +13,6 @@ export default function Auth() {
const { userInfo } = useUserStore(
useShallow((state) => ({
userInfo: state.userInfo,
showLogin: state.showLogin,
setShowLogin: state.setShowLogin,
})),
);

@ -1,3 +1,4 @@
export { default as App } from './App';
export { default as Logo } from './Logo';
export { default as Header } from './Header/Header';
export { default as Footer } from './Footer/Footer';

@ -1,3 +1,8 @@
/**
* UserInfo
* https://github.com/pmndrs/zustand/blob/main/docs/integrations/persisting-store-data.md#usage-in-nextjs
*/
import { produce } from 'immer';
// import { setCookie } from 'nookies';
import { create } from 'zustand';

Loading…
Cancel
Save