生产管理系统 修复手机端代码
This commit is contained in:
@@ -170,21 +170,6 @@ const defaultSideBarData: SideBarData = {
|
||||
]
|
||||
};
|
||||
|
||||
// 转换 SideBarData 为 MenuItem 格式的工具函数
|
||||
const convertSideBarDataToMenus = (sideBarData?: SideBarData): MenuItem[] => {
|
||||
if (!sideBarData?.navMain) return [];
|
||||
|
||||
return sideBarData.navMain.map(item => ({
|
||||
id: item.url.replace(/\/[^\/]+/g, '').replace('/', '') || item.title.replace(/\s+/g, '-').toLowerCase(),
|
||||
label: item.title,
|
||||
icon: <span className="text-lg">{item.icon}</span>,
|
||||
children: item.items?.map(child => ({
|
||||
id: child.url.split('/').pop() || child.title.replace(/\s+/g, '-').toLowerCase(),
|
||||
label: child.title,
|
||||
path: child.url,
|
||||
})),
|
||||
}));
|
||||
};
|
||||
|
||||
export function SideBarOld({
|
||||
children,
|
||||
@@ -199,7 +184,19 @@ export function SideBarOld({
|
||||
const [currentPath, setCurrentPath] = useState(pathname || activePath || '/machinery/list');
|
||||
|
||||
// 使用传入的数据或默认数据
|
||||
const menus = convertSideBarDataToMenus(data || defaultSideBarData);
|
||||
const sidebarData = data || defaultSideBarData;
|
||||
|
||||
// 转换为 MenuItem 格式以兼容 LeftSidebar 组件
|
||||
const menus = sidebarData.navMain.map(item => ({
|
||||
id: item.url.replace(/\/[^\/]+/g, '').replace('/', '') || item.title.replace(/\s+/g, '-').toLowerCase(),
|
||||
label: item.title,
|
||||
icon: <span className="text-lg">{item.icon}</span>,
|
||||
children: item.items?.map(child => ({
|
||||
id: child.url.split('/').pop() || child.title.replace(/\s+/g, '-').toLowerCase(),
|
||||
label: child.title,
|
||||
path: child.url,
|
||||
})),
|
||||
}));
|
||||
|
||||
// 检测是否为移动设备
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user