Commit 4f05dce0 authored by chenshouchao's avatar chenshouchao

feat: 解决路由相关问题

parent 41b27713
import style from "./index.module.css";
const CardTable = () => {
interface ICardTableProps {
data: Array<any>;
renderItem: any;
}
const CardTable = (props: ICardTableProps) => {
const { data, renderItem } = props;
return <div>CardTable</div>;
};
......
......@@ -14,7 +14,6 @@ const Code = (props: ICodeType) => {
return (
<CodeMirror
height={height || "100%"}
// maxWidth="200px"
width={width || "100%"}
maxWidth={maxWidth || "100%"}
value={value}
......
......@@ -44,12 +44,16 @@ const useMyRouter = () => {
});
}
for (let item of menuInfo.res.data) {
let routeHead = `/${item.type}` || '/'
let childrenRoutes: any = []
for (let route of item.routes) {
route.element = elements[route.element] || NotFound;
route.path = `/product/${item.id}${route.path}`;
route.path = `${routeHead}/${item.id}${route.path}`
if (Array.isArray(route.children)) {
route.children.forEach((childrenItem: any, index: number) => {
console.log(route)
console.log(childrenItem)
console.log(routeHead)
if (childrenItem.path) {
childrenRoutes.push({
...childrenItem,
......@@ -59,10 +63,10 @@ const useMyRouter = () => {
})
}
})
// http://localhost:8088/v3/product/resourceCenter/userResources/seeEnv
route.children = route.children.filter((childrenItem: any) => !childrenItem.path)
}
}
// permissionStore.setAddRoutes(item.routes);
permissionStore.setAddRoutes([...childrenRoutes, ...item.routes]);
}
menuStore.initMenu(menuInfo.res.data);
......
......@@ -70,6 +70,11 @@ export const routes: Array<route | navigate> = [
from: "/",
to: "/home",
},
{
type: "navigate",
from: "/utility",
to: "/home",
},
{
type: "navigate",
from: "/product",
......@@ -87,6 +92,13 @@ export const routes: Array<route | navigate> = [
path: "/home",
element: Home,
},
{
type: "page",
name: "Utility",
path: "/utility",
element: MenuLayout,
children: [],
},
{
type: "page",
name: "Product",
......
......@@ -38,7 +38,11 @@ class Permission {
if (route.type === "page" && route.children) {
if (route.name === "Product") {
for (let item of this.addRoutes) {
route.children.push(...item);
route.children.push(...item.filter((a) => a.path.indexOf('product/') !== -1));
}
} else if (route.name === "Utility") {
for (let item of this.addRoutes) {
route.children.push(...item.filter((a) => a.path.indexOf('utility/') !== -1));
}
} else {
this.AddInsertRoutes(route.children);
......
......@@ -144,7 +144,7 @@ const SeeEnv = () => {
className={style.goBackIcon}
src={goback}
alt=""
onClick={() => navigate("/product/resourceCenter/userResources")}
onClick={() => navigate("/utility/resourceCenter/userResources")}
/>
<div className={style.title}>{info.title}</div>
<div className={style.type}>
......
......@@ -131,9 +131,7 @@ const UserResourcesEnvironment = () => {
};
const hanleToSeeEnv = (item: any) => {
console.log("hanleToSeeEnv");
console.log(item.id);
navigate("/product/resourceCenter/userResources/seeEnv", {
navigate("/utility/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