feat:个人中心页完成

This commit is contained in:
许永平
2025-07-04 14:03:04 +08:00
parent dbc61c54bb
commit f771a73444
4 changed files with 88 additions and 23 deletions

View File

@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { BrowserRouter, Routes, Route } from 'react-router-dom'; import { BrowserRouter, Routes, Route } from 'react-router-dom';
import LayoutWrapper from './components/LayoutWrapper';
import Home from './pages/Home'; import Home from './pages/Home';
import Login from './pages/login/Login'; import Login from './pages/login/Login';
import Devices from './pages/devices/Devices'; import Devices from './pages/devices/Devices';
@@ -23,6 +24,7 @@ import Content from './pages/content/Content';
function App() { function App() {
return ( return (
<BrowserRouter> <BrowserRouter>
<LayoutWrapper>
<Routes> <Routes>
<Route path="/" element={<Home />} /> <Route path="/" element={<Home />} />
<Route path="/login" element={<Login />} /> <Route path="/login" element={<Login />} />
@@ -45,6 +47,7 @@ function App() {
<Route path="/content" element={<Content />} /> <Route path="/content" element={<Content />} />
{/* 你可以继续添加更多路由 */} {/* 你可以继续添加更多路由 */}
</Routes> </Routes>
</LayoutWrapper>
</BrowserRouter> </BrowserRouter>
); );
} }

View File

@@ -0,0 +1,38 @@
import React from 'react';
import { Link, useLocation } from 'react-router-dom';
import { Home, Users, User, Briefcase } from 'lucide-react';
const navItems = [
{ href: "/", icon: Home, label: "首页" },
{ href: "/scenarios", icon: Users, label: "场景获客" },
{ href: "/workspace", icon: Briefcase, label: "工作台" },
{ href: "/profile", icon: User, label: "我的" },
];
export default function BottomNav() {
const location = useLocation();
return (
<nav className="fixed bottom-0 left-0 right-0 bg-white border-t border-gray-200 z-50">
<div className="w-full mx-auto flex justify-around">
{navItems.map((item) => {
const IconComponent = item.icon;
const isActive = location.pathname === item.href;
return (
<Link
key={item.href}
to={item.href}
className={`flex flex-col items-center py-2 px-3 ${
isActive ? "text-blue-500" : "text-gray-500"
}`}
>
<IconComponent className="w-6 h-6" />
<span className="text-xs mt-1">{item.label}</span>
</Link>
);
})}
</div>
</nav>
);
}

View File

@@ -0,0 +1,24 @@
import React from 'react';
import { useLocation } from 'react-router-dom';
import BottomNav from './BottomNav';
interface LayoutWrapperProps {
children: React.ReactNode;
}
export default function LayoutWrapper({ children }: LayoutWrapperProps) {
const location = useLocation();
// 只在四个主页显示底部导航栏:首页、场景获客、工作台和我的
const mainPages = ["/", "/scenarios", "/workspace", "/profile"];
const showBottomNav = mainPages.includes(location.pathname);
return (
<div className="mx-auto w-full">
<main className="w-full mx-auto bg-white min-h-screen flex flex-col relative lg:max-w-7xl xl:max-w-[1200px]">
{children}
{showBottomNav && <BottomNav />}
</main>
</div>
);
}

View File

@@ -147,7 +147,7 @@ export default function Home() {
}; };
return ( return (
<div className="flex-1 overflow-y-auto pb-16 bg-gray-50"> <div className="flex-1 overflow-y-auto pb-20 bg-gray-50">
<header className="sticky top-0 z-10 bg-white border-b"> <header className="sticky top-0 z-10 bg-white border-b">
<div className="flex justify-between items-center p-4"> <div className="flex justify-between items-center p-4">
<h1 className="text-xl font-semibold text-blue-600"></h1> <h1 className="text-xl font-semibold text-blue-600"></h1>