路由修复
This commit is contained in:
@@ -14,13 +14,27 @@ const Sidebar = ({ collapsed }) => {
|
||||
const { isDarkMode } = useTheme();
|
||||
const { user } = useAuth();
|
||||
|
||||
const getSelectedKeys = useMemo(() => {
|
||||
const pathname = location.pathname.substring(1);
|
||||
|
||||
const pathParts = pathname.split('/');
|
||||
let key = '';
|
||||
|
||||
if (pathParts.length >= 2) {
|
||||
const baseKey = `${pathParts[0]}/${pathParts[1]}`;
|
||||
key = pathname.includes('/') ? baseKey : pathname;
|
||||
} else {
|
||||
key = pathname;
|
||||
}
|
||||
|
||||
return [key];
|
||||
}, [location.pathname]);
|
||||
|
||||
const menuClient = useMemo(() => {
|
||||
if (!user?.id || user.menukeys?.length === 0) return [];
|
||||
return getMenuItems(user?.menukeys || []);
|
||||
}, [user]);
|
||||
useEffect(()=>{
|
||||
console.log(menuClient,'menuClient');
|
||||
},[menuClient])
|
||||
|
||||
const defaultOpenKeys = useMemo(() => {
|
||||
const pathSegments = location.pathname.split("/").filter(Boolean);
|
||||
return pathSegments.reduce((acc, _, index) => {
|
||||
@@ -48,7 +62,7 @@ useEffect(()=>{
|
||||
<Menu
|
||||
theme={isDarkMode ? "dark" : "light"}
|
||||
mode="inline"
|
||||
selectedKeys={[location.pathname]}
|
||||
selectedKeys={getSelectedKeys}
|
||||
defaultOpenKeys={defaultOpenKeys}
|
||||
items={menuClient}
|
||||
onClick={handleMenuClick}
|
||||
|
||||
@@ -57,6 +57,7 @@ export default function MenuManagement() {
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
fixed:'right',
|
||||
render: (_, record) => (
|
||||
<Space>
|
||||
<Button
|
||||
|
||||
@@ -75,6 +75,14 @@ export const allRoutes = [
|
||||
hidden: true,
|
||||
key: "company/quotaInfo",
|
||||
},
|
||||
{
|
||||
path: "quotaInfo/preview/:id?", // 添加可选的 id 参数
|
||||
hidden: true,
|
||||
component: lazy(() => import("@/pages/company/quotation/view")),
|
||||
name: "报价单预览",
|
||||
icon: "file",
|
||||
key:'company/quotaInfo/preview'
|
||||
},
|
||||
{
|
||||
path: "project",
|
||||
component: lazy(() => import("@/pages/company/project")),
|
||||
@@ -104,6 +112,15 @@ export const allRoutes = [
|
||||
icon: "appstore",
|
||||
key: "company/serviceTemplate",
|
||||
},
|
||||
{
|
||||
path: "serviceTemplateInfo/:id?",
|
||||
hidden: true,
|
||||
component: lazy(() => import("@/pages/company/service/detail")),
|
||||
name: "服务模版详情",
|
||||
icon: "container",
|
||||
key: "company/serviceTemplateInfo",
|
||||
|
||||
},
|
||||
{
|
||||
path: "supplier",
|
||||
component: lazy(() => import("@/pages/company/supplier")),
|
||||
@@ -134,7 +151,14 @@ export const allRoutes = [
|
||||
icon: "appstore",
|
||||
hidden: true,
|
||||
key: "company/projectView",
|
||||
}
|
||||
},
|
||||
{
|
||||
path: "templateItemManage",
|
||||
component: lazy(() => import("@/pages/company/service/itemsManange")),
|
||||
name: "资源类型",
|
||||
icon: "container",
|
||||
key:'company/templateItemManage'
|
||||
},
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user