32 lines
890 B
TypeScript
32 lines
890 B
TypeScript
'use client';
|
|
|
|
import { useEffect } from 'react';
|
|
import { useRouter } from 'next/navigation';
|
|
import { useAuth } from '@/lib/auth';
|
|
|
|
export default function Home() {
|
|
const router = useRouter();
|
|
const { user, isLoading } = useAuth();
|
|
|
|
useEffect(() => {
|
|
if (!isLoading) {
|
|
if (user) {
|
|
// 已登录用户重定向到分析页面
|
|
router.push('/analytics');
|
|
} else {
|
|
// 未登录用户重定向到登录页面
|
|
router.push('/login');
|
|
}
|
|
}
|
|
}, [user, isLoading, router]);
|
|
|
|
// 显示加载指示器
|
|
return (
|
|
<div className="flex items-center justify-center min-h-screen">
|
|
<div className="text-center">
|
|
<div className="animate-spin rounded-full h-16 w-16 border-t-2 border-b-2 border-blue-500 mx-auto"></div>
|
|
<p className="mt-4 text-lg text-gray-700">正在加载...</p>
|
|
</div>
|
|
</div>
|
|
);
|
|
} |