diff --git a/components/auth/auth-guard.tsx b/components/auth/auth-guard.tsx index 4430fbb..24b96af 100644 --- a/components/auth/auth-guard.tsx +++ b/components/auth/auth-guard.tsx @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'; import { useRouter, usePathname } from 'next/navigation'; -import { checkAuth, isAuthenticated } from '@/lib/auth'; +import { checkAuth, getUserProfile, isAuthenticated } from '@/lib/auth'; import GlobalLoad from '../common/GlobalLoad'; interface AuthGuardProps { @@ -36,12 +36,10 @@ export default function AuthGuard({ children }: AuthGuardProps) { try { // 调用鉴权接口验证token - const isValid = await checkAuth(); - - if (isValid) { + const user = await getUserProfile(); + if (user) { setIsAuthorized(true); } else { - // Token无效,重定向到登录页 router.push('/login'); } } catch (error) { diff --git a/components/layout/top-bar.tsx b/components/layout/top-bar.tsx index f003157..0508606 100644 --- a/components/layout/top-bar.tsx +++ b/components/layout/top-bar.tsx @@ -268,8 +268,8 @@ export function TopBar({ {/* User Info */}