feat: Add session update on dashboard navigation

This commit is contained in:
wood chen 2025-02-21 22:38:44 +08:00
parent 1050a8f6af
commit efc5dd6b39

View File

@ -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();