Files
cunkebao_v3/nkebao/src/components/LayoutWrapper.tsx

52 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-07-04 14:03:04 +08:00
import React from 'react';
import { useLocation } from 'react-router-dom';
import BottomNav from './BottomNav';
2025-07-04 15:49:22 +08:00
// 不需要底部导航的页面路径
const NO_BOTTOM_NAV_PATHS = [
'/login',
'/register',
'/forgot-password',
'/reset-password',
'/devices',
'/devices/',
'/wechat-accounts',
'/wechat-accounts/',
'/scenarios/new',
'/scenarios/',
'/plans/',
'/workspace/auto-group/',
'/workspace/moments-sync/',
'/workspace/traffic-distribution/',
'/workspace/auto-like',
2025-07-04 15:49:22 +08:00
'/404',
'/500'
];
2025-07-04 14:03:04 +08:00
interface LayoutWrapperProps {
children: React.ReactNode;
}
export default function LayoutWrapper({ children }: LayoutWrapperProps) {
const location = useLocation();
2025-07-04 15:49:22 +08:00
// 检查当前路径是否需要底部导航
const shouldShowBottomNav = !NO_BOTTOM_NAV_PATHS.some(path =>
location.pathname.startsWith(path)
);
// 如果是登录页面,直接渲染内容(不显示底部导航)
if (location.pathname === '/login') {
return <>{children}</>;
}
2025-07-04 14:03:04 +08:00
2025-07-04 15:49:22 +08:00
// 其他页面显示底部导航
2025-07-04 14:03:04 +08:00
return (
2025-07-04 15:49:22 +08:00
<div className="flex flex-col h-screen">
2025-07-04 16:11:02 +08:00
<div className="flex-1 overflow-y-auto">
2025-07-04 14:03:04 +08:00
{children}
2025-07-04 15:49:22 +08:00
</div>
{shouldShowBottomNav && <BottomNav />}
2025-07-04 14:03:04 +08:00
</div>
);
}