路由修复
This commit is contained in:
@@ -14,13 +14,27 @@ const Sidebar = ({ collapsed }) => {
|
|||||||
const { isDarkMode } = useTheme();
|
const { isDarkMode } = useTheme();
|
||||||
const { user } = useAuth();
|
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(() => {
|
const menuClient = useMemo(() => {
|
||||||
if (!user?.id || user.menukeys?.length === 0) return [];
|
if (!user?.id || user.menukeys?.length === 0) return [];
|
||||||
return getMenuItems(user?.menukeys || []);
|
return getMenuItems(user?.menukeys || []);
|
||||||
}, [user]);
|
}, [user]);
|
||||||
useEffect(()=>{
|
|
||||||
console.log(menuClient,'menuClient');
|
|
||||||
},[menuClient])
|
|
||||||
const defaultOpenKeys = useMemo(() => {
|
const defaultOpenKeys = useMemo(() => {
|
||||||
const pathSegments = location.pathname.split("/").filter(Boolean);
|
const pathSegments = location.pathname.split("/").filter(Boolean);
|
||||||
return pathSegments.reduce((acc, _, index) => {
|
return pathSegments.reduce((acc, _, index) => {
|
||||||
@@ -48,7 +62,7 @@ useEffect(()=>{
|
|||||||
<Menu
|
<Menu
|
||||||
theme={isDarkMode ? "dark" : "light"}
|
theme={isDarkMode ? "dark" : "light"}
|
||||||
mode="inline"
|
mode="inline"
|
||||||
selectedKeys={[location.pathname]}
|
selectedKeys={getSelectedKeys}
|
||||||
defaultOpenKeys={defaultOpenKeys}
|
defaultOpenKeys={defaultOpenKeys}
|
||||||
items={menuClient}
|
items={menuClient}
|
||||||
onClick={handleMenuClick}
|
onClick={handleMenuClick}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ export default function MenuManagement() {
|
|||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
key: 'action',
|
key: 'action',
|
||||||
|
fixed:'right',
|
||||||
render: (_, record) => (
|
render: (_, record) => (
|
||||||
<Space>
|
<Space>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -75,6 +75,14 @@ export const allRoutes = [
|
|||||||
hidden: true,
|
hidden: true,
|
||||||
key: "company/quotaInfo",
|
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",
|
path: "project",
|
||||||
component: lazy(() => import("@/pages/company/project")),
|
component: lazy(() => import("@/pages/company/project")),
|
||||||
@@ -104,6 +112,15 @@ export const allRoutes = [
|
|||||||
icon: "appstore",
|
icon: "appstore",
|
||||||
key: "company/serviceTemplate",
|
key: "company/serviceTemplate",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "serviceTemplateInfo/:id?",
|
||||||
|
hidden: true,
|
||||||
|
component: lazy(() => import("@/pages/company/service/detail")),
|
||||||
|
name: "服务模版详情",
|
||||||
|
icon: "container",
|
||||||
|
key: "company/serviceTemplateInfo",
|
||||||
|
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "supplier",
|
path: "supplier",
|
||||||
component: lazy(() => import("@/pages/company/supplier")),
|
component: lazy(() => import("@/pages/company/supplier")),
|
||||||
@@ -134,7 +151,14 @@ export const allRoutes = [
|
|||||||
icon: "appstore",
|
icon: "appstore",
|
||||||
hidden: true,
|
hidden: true,
|
||||||
key: "company/projectView",
|
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