22301069 | a457d80 | 2025-06-14 21:10:54 +0800 | [diff] [blame] | 1 | import React from 'react'; |
| 2 | import { BrowserRouter, Routes, Route, Navigate, useParams } from 'react-router-dom'; |
| 3 | import UserProfile from './components/UserProfile'; |
| 4 | import { FaHome, FaSearch, FaPlus, FaHeart, FaUser } from 'react-icons/fa'; |
| 5 | |
| 6 | function App() { |
| 7 | return ( |
| 8 | <BrowserRouter> |
| 9 | <div className="min-h-screen bg-gray-50"> |
| 10 | {/* 顶部导航栏 */} |
| 11 | <header className="bg-white shadow-sm sticky top-0 z-10"> |
| 12 | <div className="max-w-6xl mx-auto px-4 py-3 flex justify-between items-center"> |
| 13 | <div className="flex items-center"> |
| 14 | <div className="text-2xl font-bold text-red-500 mr-2">小红书</div> |
| 15 | <div className="hidden md:block text-sm text-gray-500">发现美好生活</div> |
| 16 | </div> |
| 17 | <div className="flex space-x-4"> |
| 18 | <a href="/user/11" className="text-gray-600 hover:text-red-500"> |
| 19 | 用户11 |
| 20 | </a> |
| 21 | <a href="/user/2" className="text-gray-600 hover:text-red-500"> |
| 22 | 用户2 |
| 23 | </a> |
| 24 | <a href="/user/3" className="text-gray-600 hover:text-red-500"> |
| 25 | 用户3 |
| 26 | </a> |
| 27 | </div> |
| 28 | </div> |
| 29 | </header> |
| 30 | |
| 31 | <main className="py-5"> |
| 32 | <div className="max-w-6xl mx-auto"> |
| 33 | <Routes> |
| 34 | <Route path="/" element={<Navigate to="/user/11" replace />} /> |
| 35 | <Route path="/user/:userId" element={<UserProfileRoute />} /> |
| 36 | </Routes> |
| 37 | </div> |
| 38 | </main> |
| 39 | |
| 40 | {/* 小红书风格底部导航栏 */} |
| 41 | <div className="fixed bottom-0 left-0 right-0 bg-white border-t border-gray-200 py-2 z-10"> |
| 42 | <div className="max-w-md mx-auto grid grid-cols-5"> |
| 43 | <button className="flex flex-col items-center text-red-500"> |
| 44 | <FaHome className="text-xl" /> |
| 45 | <span className="text-xs mt-1">首页</span> |
| 46 | </button> |
| 47 | <button className="flex flex-col items-center text-gray-500"> |
| 48 | <FaSearch className="text-xl" /> |
| 49 | <span className="text-xs mt-1">发现</span> |
| 50 | </button> |
| 51 | <button className="flex flex-col items-center text-gray-500"> |
| 52 | <div className="bg-red-500 rounded-full p-2 -mt-3"> |
| 53 | <FaPlus className="text-white text-lg" /> |
| 54 | </div> |
| 55 | <span className="text-xs mt-2">发布</span> |
| 56 | </button> |
| 57 | <button className="flex flex-col items-center text-gray-500"> |
| 58 | <FaHeart className="text-xl" /> |
| 59 | <span className="text-xs mt-1">消息</span> |
| 60 | </button> |
| 61 | <button className="flex flex-col items-center text-gray-500"> |
| 62 | <FaUser className="text-xl" /> |
| 63 | <span className="text-xs mt-1">我</span> |
| 64 | </button> |
| 65 | </div> |
| 66 | </div> |
| 67 | </div> |
| 68 | </BrowserRouter> |
| 69 | ); |
| 70 | } |
| 71 | |
| 72 | function UserProfileRoute() { |
| 73 | const { userId } = useParams(); |
| 74 | return <UserProfile userId={parseInt(userId)} />; |
| 75 | } |
| 76 | |
| 77 | export default App; |