import React from 'react'; import { useNavigate } from 'react-router-dom'; import { NavBar, TabBar, Badge } from 'antd-mobile'; import { AppOutline, SearchOutline, AddCircleOutline, SetOutline, BellOutline } from 'antd-mobile-icons'; import { useNotificationStore } from '../../stores'; import './index.css'; interface LayoutProps { children: React.ReactNode; title?: string; showBack?: boolean; showTabBar?: boolean; } const Layout: React.FC = ({ children, title = '药箱', showBack = false, showTabBar = true }) => { const navigate = useNavigate(); const { unreadCount } = useNotificationStore(); const tabs = [ { key: '/', title: '首页', icon: }, { key: '/medicines', title: '药品', icon: }, { key: '/quick-dispense', title: '取药', icon: }, { key: '/notifications', title: '通知', icon: 0 ? unreadCount : null}> }, { key: '/settings', title: '设置', icon: } ]; const handleTabChange = (key: string) => { navigate(key); }; return (
navigate(-1) : undefined} backArrow={showBack} > {title}
{children}
{showTabBar && (
window.location.pathname.startsWith(t.key))?.key || '/'} onChange={handleTabChange}> {tabs.map(item => ( ))}
)}
); }; export default Layout;