2022-10-25 17:51:21 +08:00
|
|
|
|
// 模拟后端动态生成路由
|
2024-03-09 16:27:52 +08:00
|
|
|
|
import { defineFakeRoute } from "vite-plugin-fake-server/client";
|
2021-10-16 16:16:58 +08:00
|
|
|
|
|
2022-10-25 17:51:21 +08:00
|
|
|
|
/**
|
2024-05-18 01:11:46 +08:00
|
|
|
|
* roles:页面级别权限,这里模拟二种 "user"、"common"
|
|
|
|
|
* user:管理员角色
|
2022-10-25 17:51:21 +08:00
|
|
|
|
* common:普通角色
|
|
|
|
|
*/
|
2021-10-16 16:16:58 +08:00
|
|
|
|
const permissionRouter = {
|
|
|
|
|
path: "/permission",
|
|
|
|
|
meta: {
|
2022-10-28 15:32:31 +08:00
|
|
|
|
title: "权限管理",
|
2024-03-09 16:27:52 +08:00
|
|
|
|
icon: "ep:lollipop",
|
2022-10-25 17:51:21 +08:00
|
|
|
|
rank: 10
|
2021-10-16 16:16:58 +08:00
|
|
|
|
},
|
|
|
|
|
children: [
|
|
|
|
|
{
|
2022-01-05 14:17:06 +08:00
|
|
|
|
path: "/permission/page/index",
|
2022-08-22 21:34:55 +08:00
|
|
|
|
name: "PermissionPage",
|
2021-10-16 16:16:58 +08:00
|
|
|
|
meta: {
|
2022-10-28 15:32:31 +08:00
|
|
|
|
title: "页面权限",
|
2024-05-18 01:11:46 +08:00
|
|
|
|
roles: ["user", "common"]
|
2021-10-16 16:16:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
2022-01-05 14:17:06 +08:00
|
|
|
|
path: "/permission/button/index",
|
2022-08-22 21:34:55 +08:00
|
|
|
|
name: "PermissionButton",
|
2021-10-16 16:16:58 +08:00
|
|
|
|
meta: {
|
2022-10-28 15:32:31 +08:00
|
|
|
|
title: "按钮权限",
|
2024-05-18 01:11:46 +08:00
|
|
|
|
roles: ["user", "common"],
|
2024-03-09 16:27:52 +08:00
|
|
|
|
auths: [
|
|
|
|
|
"permission:btn:add",
|
|
|
|
|
"permission:btn:edit",
|
|
|
|
|
"permission:btn:delete"
|
|
|
|
|
]
|
2021-10-16 16:16:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
|
2024-03-09 16:27:52 +08:00
|
|
|
|
export default defineFakeRoute([
|
2021-10-16 16:16:58 +08:00
|
|
|
|
{
|
2024-03-09 16:27:52 +08:00
|
|
|
|
url: "/get-async-routes",
|
2021-10-16 16:16:58 +08:00
|
|
|
|
method: "get",
|
2022-10-25 17:51:21 +08:00
|
|
|
|
response: () => {
|
|
|
|
|
return {
|
|
|
|
|
success: true,
|
|
|
|
|
data: [permissionRouter]
|
|
|
|
|
};
|
2021-10-16 16:16:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-09 16:27:52 +08:00
|
|
|
|
]);
|