diff --git a/crop-x/src/app/layout.tsx b/crop-x/src/app/layout.tsx
index d950d9e..c243284 100644
--- a/crop-x/src/app/layout.tsx
+++ b/crop-x/src/app/layout.tsx
@@ -1,5 +1,5 @@
'use client';
-
+import "@/styles/globals.css"
import { useEffect } from 'react';
import { AuthProvider } from '@/components/auth/AuthContext';
import { ClientAuthInterceptor } from '@/components/auth/ClientAuthInterceptor';
diff --git a/crop-x/src/app/page.tsx b/crop-x/src/app/page.tsx
index cd1c42b..3b1eca7 100644
--- a/crop-x/src/app/page.tsx
+++ b/crop-x/src/app/page.tsx
@@ -1,30 +1,10 @@
'use client';
-import { useAuth } from '@/components/auth/AuthContext';
-import { LoadingScreen } from '@/components/auth/LoadingScreen';
-import { redirect } from 'next/navigation';
-
export default function HomePage() {
- const { user, loading, isAuthenticated } = useAuth();
-
- // 如果正在加载,显示加载屏幕
- if (loading) {
- return ;
- }
- console.log('isAuthenticated:',isAuthenticated)
- // 如果未认证,重定向到登录页
- if (!isAuthenticated) {
- redirect('/login');
- }
-
- // 如果已认证,重定向到个人中心
- if (isAuthenticated) {
- redirect('/central-config/personal-center/personal-info');
- }
-
- // 兜底显示(一般不会执行到这里)
return (
-
+
+
+
);
}
\ No newline at end of file
diff --git a/crop-x/src/components/auth/ClientAuthInterceptor.tsx b/crop-x/src/components/auth/ClientAuthInterceptor.tsx
index c7a057b..47f27f5 100644
--- a/crop-x/src/components/auth/ClientAuthInterceptor.tsx
+++ b/crop-x/src/components/auth/ClientAuthInterceptor.tsx
@@ -3,6 +3,7 @@
import { useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { useAuth } from './AuthContext';
+import { LoadingScreen } from './loadingScreen';
interface ClientAuthInterceptorProps {
children: React.ReactNode;
@@ -43,14 +44,7 @@ export function ClientAuthInterceptor({ children }: ClientAuthInterceptorProps)
// 如果正在加载,显示加载状态
if (loading) {
- return (
-
- );
+ return ;
}
// 如果在认证页面(包括 /login 开头的所有路径),直接渲染子组件,不需要认证检查
@@ -60,14 +54,7 @@ export function ClientAuthInterceptor({ children }: ClientAuthInterceptorProps)
// 如果未认证且不在认证页面,显示跳转状态
if (!isAuthenticated) {
- return (
-
- );
+ return ;
}
// 认证通过,渲染子组件
diff --git a/crop-x/src/components/auth/LoadingScreen.tsx b/crop-x/src/components/auth/LoadingScreen.tsx
index 2185478..ccf8787 100644
--- a/crop-x/src/components/auth/LoadingScreen.tsx
+++ b/crop-x/src/components/auth/LoadingScreen.tsx
@@ -2,29 +2,49 @@
import React from 'react';
import { Loader2 } from 'lucide-react';
+import { SmartFieldBackground } from './SmartFieldBackground';
interface LoadingScreenProps {
message?: string;
+ subMessage?: string;
+ variant?: 'default' | 'auth' | 'redirect';
}
-export function LoadingScreen({ message = '正在验证用户身份...' }: LoadingScreenProps) {
+export function LoadingScreen({
+ message,
+ subMessage,
+ variant = 'default'
+}: LoadingScreenProps) {
return (
-
-
-
-
-
-
智慧农业生产管理系统
-
{message}
+
+ {/* 智慧大田动态背景 - 使用登录页面相同的背景效果 */}
+
- {/* 加载进度条 */}
-
-
+ {/* 主要内容 */}
+
+ {/* 大型加载器 */}
+
+ {/* 外圈 */}
+
+ {/* 中圈 */}
+
+ {/* 内圈 */}
+
+ {/* 中心 */}
+
+ {/* Loader2 */}
+
+
+
- {/* 提示信息 */}
-
-
正在验证您的身份信息,请稍候...
+ {/* 加载标题 */}
+