mirror of
https://github.com/woodchen-ink/Q58Connect.git
synced 2025-07-18 05:51:55 +08:00
feat: Add session update on dashboard navigation
This commit is contained in:
parent
1050a8f6af
commit
efc5dd6b39
@ -21,11 +21,18 @@ import { ThemeToggle } from "../theme-toggle";
|
||||
import { Button } from "../ui/button";
|
||||
|
||||
export function NavBar() {
|
||||
const { data: session, status } = useSession();
|
||||
const { data: session, status, update } = useSession();
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const user = session?.user;
|
||||
|
||||
useEffect(() => {
|
||||
// 当路由变化时,尝试更新 session
|
||||
if (pathname === "/dashboard" || pathname.startsWith("/dashboard/")) {
|
||||
update();
|
||||
}
|
||||
}, [pathname, update]);
|
||||
|
||||
const handleSignOut = async () => {
|
||||
await signOut({ redirect: false });
|
||||
router.refresh();
|
||||
|
Loading…
x
Reference in New Issue
Block a user