Commit f10e4896 authored by chenshouchao's avatar chenshouchao

feat: 路由修改

parent 6704e629
......@@ -43,18 +43,26 @@ const useMyRouter = () => {
});
}
for (let item of menuInfo.res.data) {
let childrenRoutes: any = []
for (let route of item.routes) {
route.element = elements[route.element] || NotFound;
route.path = `/product/${item.id}${route.path}`;
if (Array.isArray(route.children)) {
route.children.forEach((childrenItem: any, index: number) => {
route.children[index].element = elements[childrenItem.element] || NotFound;
route.children[index].path = `${route.path}${childrenItem.path}`;
if (childrenItem.path) {
childrenRoutes.push({
...childrenItem,
element: elements[childrenItem.element] || NotFound,
path: `${route.path}${childrenItem.path}`,
show: false
})
}
})
route.children = route.children.filter((childrenItem: any) => !childrenItem.path)
}
}
console.log(item.routes)
permissionStore.setAddRoutes(item.routes);
// permissionStore.setAddRoutes(item.routes);
permissionStore.setAddRoutes([...childrenRoutes, ...item.routes]);
}
menuStore.initMenu(menuInfo.res.data);
permissionStore.initAllRoutes();
......
......@@ -85,7 +85,8 @@ const MenuLayout = observer(() => {
key={"sidebar" + index}
className={classnames({
[style.listItem]: true,
[style.active]: `/v3${item.path}` === pathname,
[style.active]: pathname.indexOf(`/v3${item.path}`) !== -1,
// [style.active]: `/v3${item.path}` === pathname,
})}
style={
`/v3${item.path}` === pathname
......
......@@ -132,9 +132,7 @@ const UserResourcesEnvironment = () => {
const hanleToSeeEnv = (item: any) => {
console.log("hanleToSeeEnv");
console.log(item.id);
// /product/userCenter/userInformation
// navigate("/product/resourceCenter/userResources/seeEnv", {
navigate("/product/userCenter/userInformation", {
navigate("/product/resourceCenter/userResources/seeEnv", {
state: { id: item.id },
});
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment