mirror of
https://github.com/woodchen-ink/Q58Connect.git
synced 2025-07-18 05:51:55 +08:00
feat: Add session update for dashboard and admin pages
This commit is contained in:
parent
47e9d686d6
commit
d5465246cb
@ -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;
|
||||
|
||||
// 在 dashboard 或 admin 页面时强制刷新一次 session
|
||||
useEffect(() => {
|
||||
if (pathname?.startsWith("/dashboard") || pathname?.startsWith("/admin")) {
|
||||
update();
|
||||
}
|
||||
}, [pathname, update]);
|
||||
|
||||
const handleSignOut = async () => {
|
||||
await signOut({ redirect: false });
|
||||
router.refresh();
|
||||
|
Loading…
x
Reference in New Issue
Block a user