2
0

HomePage.tsx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import React from 'react';
  2. import { useAuth } from '@/client/home/hooks/AuthProvider';
  3. import { useNavigate } from 'react-router-dom';
  4. const HomePage: React.FC = () => {
  5. const { user } = useAuth();
  6. const navigate = useNavigate();
  7. return (
  8. <div className="min-h-screen bg-gray-50 flex flex-col">
  9. {/* 顶部导航 */}
  10. <header className="bg-blue-600 text-white shadow-md fixed w-full z-10">
  11. <div className="container mx-auto px-4 py-3 flex justify-between items-center">
  12. <h1 className="text-xl font-bold">网站首页</h1>
  13. {user ? (
  14. <div className="flex items-center space-x-4">
  15. <div className="flex items-center cursor-pointer" onClick={() => navigate(`/member`)}>
  16. <div className="w-8 h-8 rounded-full bg-white text-blue-600 flex items-center justify-center mr-2">
  17. <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
  18. <path fillRule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clipRule="evenodd" />
  19. </svg>
  20. </div>
  21. <span className="hidden md:inline">{user.username}</span>
  22. </div>
  23. </div>
  24. ) : (
  25. <div className="flex space-x-2">
  26. <button
  27. onClick={() => navigate('/login')}
  28. className="px-3 py-1 rounded text-sm bg-white text-blue-600 hover:bg-blue-50"
  29. >
  30. 登录
  31. </button>
  32. <button
  33. onClick={() => navigate('/register')}
  34. className="px-3 py-1 rounded text-sm bg-white text-blue-600 hover:bg-blue-50"
  35. >
  36. 注册
  37. </button>
  38. </div>
  39. )}
  40. </div>
  41. </header>
  42. {/* 主内容区 */}
  43. <main className="flex-grow container mx-auto px-4 pt-24 pb-12">
  44. <div className="bg-white rounded-lg shadow-sm p-6 md:p-8">
  45. <h2 className="text-2xl font-bold text-gray-900 mb-4">欢迎使用网站模板</h2>
  46. <p className="text-gray-600 mb-6">
  47. 这是一个通用的网站首页模板,您可以根据需要进行自定义。
  48. 已包含基础的登录、注册和用户中心功能。
  49. </p>
  50. <div className="grid grid-cols-1 md:grid-cols-3 gap-6 mt-8">
  51. <div className="bg-blue-50 p-5 rounded-lg text-center">
  52. <div className="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-4">
  53. <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">
  54. <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" />
  55. </svg>
  56. </div>
  57. <h3 className="font-semibold text-lg mb-2">用户认证</h3>
  58. <p className="text-gray-600 text-sm">完整的登录、注册功能,保护您的网站安全</p>
  59. </div>
  60. <div className="bg-green-50 p-5 rounded-lg text-center">
  61. <div className="w-12 h-12 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4">
  62. <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">
  63. <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" />
  64. </svg>
  65. </div>
  66. <h3 className="font-semibold text-lg mb-2">用户中心</h3>
  67. <p className="text-gray-600 text-sm">用户可以查看和管理个人信息</p>
  68. </div>
  69. <div className="bg-purple-50 p-5 rounded-lg text-center">
  70. <div className="w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-4">
  71. <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">
  72. <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" />
  73. </svg>
  74. </div>
  75. <h3 className="font-semibold text-lg mb-2">响应式设计</h3>
  76. <p className="text-gray-600 text-sm">适配各种设备屏幕,提供良好的用户体验</p>
  77. </div>
  78. </div>
  79. </div>
  80. </main>
  81. {/* 页脚 */}
  82. <footer className="bg-white border-t border-gray-200 py-4">
  83. <div className="container mx-auto px-4 text-center text-gray-500 text-sm">
  84. 网站模板 ©{new Date().getFullYear()} Created with React & Tailwind CSS
  85. <div className="mt-2 space-x-4">
  86. <a href="/admin" className="text-blue-600 hover:underline">管理后台</a>
  87. <span className="text-gray-300">|</span>
  88. <a href="/ui" className="text-blue-600 hover:underline">Api</a>
  89. </div>
  90. </div>
  91. </footer>
  92. </div>
  93. );
  94. };
  95. export default HomePage;