| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- import React from 'react';
- import { useAuth } from '@/client/home/hooks/AuthProvider';
- import { useNavigate } from 'react-router-dom';
- const HomePage: React.FC = () => {
- const { user } = useAuth();
- const navigate = useNavigate();
- return (
- <div className="min-h-screen bg-gray-50 flex flex-col">
- {/* 顶部导航 */}
- <header className="bg-blue-600 text-white shadow-md fixed w-full z-10">
- <div className="container mx-auto px-4 py-3 flex justify-between items-center">
- <h1 className="text-xl font-bold">网站首页</h1>
- {user ? (
- <div className="flex items-center space-x-4">
- <div className="flex items-center cursor-pointer" onClick={() => navigate(`/member`)}>
- <div className="w-8 h-8 rounded-full bg-white text-blue-600 flex items-center justify-center mr-2">
- <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
- <path fillRule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clipRule="evenodd" />
- </svg>
- </div>
- <span className="hidden md:inline">{user.username}</span>
- </div>
- </div>
- ) : (
- <div className="flex space-x-2">
- <button
- onClick={() => navigate('/login')}
- className="px-3 py-1 rounded text-sm bg-white text-blue-600 hover:bg-blue-50"
- >
- 登录
- </button>
- <button
- onClick={() => navigate('/register')}
- className="px-3 py-1 rounded text-sm bg-white text-blue-600 hover:bg-blue-50"
- >
- 注册
- </button>
- </div>
- )}
- </div>
- </header>
-
- {/* 主内容区 */}
- <main className="flex-grow container mx-auto px-4 pt-24 pb-12">
- <div className="bg-white rounded-lg shadow-sm p-6 md:p-8">
- <h2 className="text-2xl font-bold text-gray-900 mb-4">欢迎使用网站模板</h2>
- <p className="text-gray-600 mb-6">
- 这是一个通用的网站首页模板,您可以根据需要进行自定义。
- 已包含基础的登录、注册和用户中心功能。
- </p>
-
- <div className="grid grid-cols-1 md:grid-cols-3 gap-6 mt-8">
- <div className="bg-blue-50 p-5 rounded-lg text-center">
- <div className="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-4">
- <svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
- </svg>
- </div>
- <h3 className="font-semibold text-lg mb-2">用户认证</h3>
- <p className="text-gray-600 text-sm">完整的登录、注册功能,保护您的网站安全</p>
- </div>
-
- <div className="bg-green-50 p-5 rounded-lg text-center">
- <div className="w-12 h-12 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4">
- <svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6 text-green-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
- </svg>
- </div>
- <h3 className="font-semibold text-lg mb-2">用户中心</h3>
- <p className="text-gray-600 text-sm">用户可以查看和管理个人信息</p>
- </div>
-
- <div className="bg-purple-50 p-5 rounded-lg text-center">
- <div className="w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-4">
- <svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6 text-purple-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4" />
- </svg>
- </div>
- <h3 className="font-semibold text-lg mb-2">响应式设计</h3>
- <p className="text-gray-600 text-sm">适配各种设备屏幕,提供良好的用户体验</p>
- </div>
- </div>
- </div>
- </main>
-
- {/* 页脚 */}
- <footer className="bg-white border-t border-gray-200 py-4">
- <div className="container mx-auto px-4 text-center text-gray-500 text-sm">
- 网站模板 ©{new Date().getFullYear()} Created with React & Tailwind CSS
- <div className="mt-2 space-x-4">
- <a href="/admin" className="text-blue-600 hover:underline">管理后台</a>
- <span className="text-gray-300">|</span>
- <a href="/ui" className="text-blue-600 hover:underline">Api</a>
- </div>
- </div>
- </footer>
- </div>
- );
- };
- export default HomePage;
|