forked from 77media/video-flow
修复一些问题
This commit is contained in:
parent
90df36a8a0
commit
c6a7889b43
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useRouter, usePathname } from 'next/navigation';
|
import { useRouter, usePathname } from 'next/navigation';
|
||||||
import { checkAuth, isAuthenticated } from '@/lib/auth';
|
import { checkAuth, getUserProfile, isAuthenticated } from '@/lib/auth';
|
||||||
import GlobalLoad from '../common/GlobalLoad';
|
import GlobalLoad from '../common/GlobalLoad';
|
||||||
|
|
||||||
interface AuthGuardProps {
|
interface AuthGuardProps {
|
||||||
@ -36,12 +36,10 @@ export default function AuthGuard({ children }: AuthGuardProps) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// 调用鉴权接口验证token
|
// 调用鉴权接口验证token
|
||||||
const isValid = await checkAuth();
|
const user = await getUserProfile();
|
||||||
|
if (user) {
|
||||||
if (isValid) {
|
|
||||||
setIsAuthorized(true);
|
setIsAuthorized(true);
|
||||||
} else {
|
} else {
|
||||||
// Token无效,重定向到登录页
|
|
||||||
router.push('/login');
|
router.push('/login');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -268,8 +268,8 @@ export function TopBar({
|
|||||||
{/* User Info */}
|
{/* User Info */}
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
<div className="flex items-center space-x-3">
|
<div className="flex items-center space-x-3">
|
||||||
<div className="h-10 w-10 rounded-full bg-[#1E4D3E] flex items-center justify-center text-white font-semibold">
|
<div className="h-10 w-10 rounded-full bg-[#C73BFF] flex items-center justify-center text-white font-semibold">
|
||||||
{currentUser.name ? currentUser.name.charAt(0) : ""}
|
MF
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<p className="text-sm font-medium">
|
<p className="text-sm font-medium">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user