import React from "react"; import { NavBar, SafeArea, TabBar } from "antd-mobile"; import { useNavigate } from "react-router-dom"; import "./index.less"; import { Translate, Electrocardiogram, GithubOne, Blossom, User } from "@icon-park/react"; interface MainLayoutProps { children: React.ReactNode; isShowNavBar?: boolean; title?: string; navBarRight?: React.ReactNode; onLink?: () => void; } const MainLayout: React.FC = ({ isShowNavBar, children, onLink, title, navBarRight, }) => { const navigate = useNavigate(); // const location = useLocation(); const [pathname, setPathname] = React.useState(location.pathname); const tabs = [ { key: "/translate", title: "宠物翻译", icon: , }, { key: "/translate/archives", title: "情绪监控", icon: , }, { key: "/translate/mood", title: "我的宠物", icon: , }, // { // key: "/translate/mood", // title: "宠物服务", // icon: , // }, // { // key: "/translate/mood", // title: "个人中心", // icon: , // }, ]; const setRouteActive = (value: string) => { console.log(value); setPathname(value); navigate(value); }; const goBack = () => { // 打印路由栈 // debugger; if (onLink) { onLink?.(); } else { navigate(-1); } }; return (
{isShowNavBar ? ( {title} ) : ( "" )}
{children}
setRouteActive(value)} safeArea={true}> {tabs.map((item) => ( ))}
); }; export default MainLayout;