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";
|
import { Button } from "../ui/button";
|
||||||
|
|
||||||
export function NavBar() {
|
export function NavBar() {
|
||||||
const { data: session, status } = useSession();
|
const { data: session, status, update } = useSession();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const user = session?.user;
|
const user = session?.user;
|
||||||
|
|
||||||
|
// 在 dashboard 或 admin 页面时强制刷新一次 session
|
||||||
|
useEffect(() => {
|
||||||
|
if (pathname?.startsWith("/dashboard") || pathname?.startsWith("/admin")) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}, [pathname, update]);
|
||||||
|
|
||||||
const handleSignOut = async () => {
|
const handleSignOut = async () => {
|
||||||
await signOut({ redirect: false });
|
await signOut({ redirect: false });
|
||||||
router.refresh();
|
router.refresh();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user