|
|
// 模拟后端动态生成路由
|
|
|
import { MockMethod } from "vite-plugin-mock";
|
|
|
|
|
|
/**
|
|
|
* roles:页面级别权限,这里模拟二种 "admin"、"common"
|
|
|
* admin:管理员角色
|
|
|
* common:普通角色
|
|
|
*/
|
|
|
|
|
|
// const permissionRouter = {
|
|
|
// path: "/permission",
|
|
|
// meta: {
|
|
|
// title: "用户管理",
|
|
|
// icon: "lollipop",
|
|
|
// rank: 10
|
|
|
// },
|
|
|
// children: [
|
|
|
// {
|
|
|
// path: "/permission/page/index",
|
|
|
// name: "PermissionPage",
|
|
|
// meta: {
|
|
|
// title: "页面权限",
|
|
|
// roles: ["admin", "common"]
|
|
|
// }
|
|
|
// },
|
|
|
// {
|
|
|
// path: "/permission/button/index",
|
|
|
// name: "PermissionButton",
|
|
|
// meta: {
|
|
|
// title: "按钮权限",
|
|
|
// roles: ["admin", "common"],
|
|
|
// auths: ["btn_add", "btn_edit", "btn_delete"]
|
|
|
// }
|
|
|
// }
|
|
|
// ]
|
|
|
// };
|
|
|
|
|
|
// const projectRouter = {
|
|
|
// path: "/project",
|
|
|
// meta: {
|
|
|
// title: "项目管理",
|
|
|
// icon: "lollipop",
|
|
|
// rank: 11
|
|
|
// },
|
|
|
// children: [
|
|
|
// {
|
|
|
// path: "/project/list/index",
|
|
|
// name: "ProjectList",
|
|
|
// meta: {
|
|
|
// title: "项目列表",
|
|
|
// roles: ["admin", "common"]
|
|
|
// }
|
|
|
// },
|
|
|
// {
|
|
|
// path: "/project/details/index",
|
|
|
// name: "ProjectDetails",
|
|
|
// meta: {
|
|
|
// title: "项目详情",
|
|
|
// roles: ["admin", "common"]
|
|
|
// }
|
|
|
// }
|
|
|
// ]
|
|
|
// };
|
|
|
|
|
|
// const modelRouter = {
|
|
|
// path: "/aiModel",
|
|
|
// meta: {
|
|
|
// title: "模型管理",
|
|
|
// icon: "lollipop",
|
|
|
// rank: 12
|
|
|
// },
|
|
|
// children: [
|
|
|
// {
|
|
|
// path: "/aiModel",
|
|
|
// name: "AiModelPage",
|
|
|
// meta: {
|
|
|
// title: "模型管理",
|
|
|
// roles: ["admin", "common"]
|
|
|
// }
|
|
|
// }
|
|
|
// ]
|
|
|
// };
|
|
|
|
|
|
// const deviceRouter = {
|
|
|
// path: "/device",
|
|
|
// meta: {
|
|
|
// title: "设备管理",
|
|
|
// icon: "lollipop",
|
|
|
// rank: 13
|
|
|
// },
|
|
|
// children: [
|
|
|
// {
|
|
|
// path: "/device",
|
|
|
// name: "DevicePage",
|
|
|
// meta: {
|
|
|
// title: "设备管理",
|
|
|
// roles: ["admin", "common"]
|
|
|
// }
|
|
|
// }
|
|
|
// ]
|
|
|
// };
|
|
|
|
|
|
// const warningRouter = {
|
|
|
// path: "/warning",
|
|
|
// meta: {
|
|
|
// title: "告警管理",
|
|
|
// icon: "Alarm",
|
|
|
// rank: 14
|
|
|
// },
|
|
|
// children: [
|
|
|
// {
|
|
|
// path: "/warning/list/index",
|
|
|
// name: "WarningList",
|
|
|
// meta: {
|
|
|
// title: "告警列表",
|
|
|
// roles: ["admin", "common"]
|
|
|
// }
|
|
|
// }
|
|
|
// ]
|
|
|
// };
|
|
|
|
|
|
const enterpriseRouter = {
|
|
|
path: "/enterprise",
|
|
|
meta: {
|
|
|
title: "企业管理",
|
|
|
icon: "lollipop",
|
|
|
rank: 15
|
|
|
},
|
|
|
children: [
|
|
|
{
|
|
|
path: "/enterprise/index",
|
|
|
name: "EnterpriseList",
|
|
|
meta: {
|
|
|
title: "企业管理",
|
|
|
roles: ["admin", "common"]
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
};
|
|
|
|
|
|
const myAlgorithmRouter = {
|
|
|
path: "/myAlgorithm",
|
|
|
meta: {
|
|
|
title: "我的算法库",
|
|
|
icon: "lollipop",
|
|
|
rank: 16
|
|
|
},
|
|
|
children: [
|
|
|
{
|
|
|
path: "/myAlgorithm/index",
|
|
|
name: "myAlgorithm",
|
|
|
meta: {
|
|
|
title: "我的算法库",
|
|
|
roles: ["admin", "common"]
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
};
|
|
|
|
|
|
const algorithmTestingRouter = {
|
|
|
path: "/algorithmTesting",
|
|
|
meta: {
|
|
|
title: "算法实测",
|
|
|
icon: "lollipop",
|
|
|
rank: 16
|
|
|
},
|
|
|
children: [
|
|
|
{
|
|
|
path: "/algorithmTesting/index",
|
|
|
name: "algorithmTesting",
|
|
|
meta: {
|
|
|
title: "算法实测",
|
|
|
roles: ["admin", "common"]
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
};
|
|
|
|
|
|
export default [
|
|
|
{
|
|
|
url: "/getAsyncRoutes",
|
|
|
method: "get",
|
|
|
response: () => {
|
|
|
return {
|
|
|
success: true,
|
|
|
data: [enterpriseRouter, myAlgorithmRouter, algorithmTestingRouter]
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
] as MockMethod[];
|