mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-04-24 23:47:17 +08:00
202 lines
4.2 KiB
TypeScript
202 lines
4.2 KiB
TypeScript
// 模拟后端动态生成路由
|
||
import { defineFakeRoute } from "vite-plugin-fake-server/client";
|
||
import { system, monitor } from "@/router/enums";
|
||
|
||
/**
|
||
* roles:页面级别权限,这里模拟二种 "admin"、"common"
|
||
* admin:管理员角色
|
||
* common:普通角色
|
||
*/
|
||
|
||
const systemManagementRouter = {
|
||
path: "/system",
|
||
meta: {
|
||
icon: "ri:settings-3-line",
|
||
title: "menus.hssysManagement",
|
||
rank: system
|
||
},
|
||
children: [
|
||
{
|
||
path: "/system/user/index",
|
||
name: "SystemUser",
|
||
meta: {
|
||
icon: "ri:admin-line",
|
||
title: "menus.hsUser",
|
||
roles: ["admin"]
|
||
}
|
||
},
|
||
{
|
||
path: "/system/role/index",
|
||
name: "SystemRole",
|
||
meta: {
|
||
icon: "ri:admin-fill",
|
||
title: "menus.hsRole",
|
||
roles: ["admin"]
|
||
}
|
||
},
|
||
{
|
||
path: "/system/menu/index",
|
||
name: "SystemMenu",
|
||
meta: {
|
||
icon: "ep:menu",
|
||
title: "menus.hsSystemMenu",
|
||
roles: ["admin"]
|
||
}
|
||
},
|
||
{
|
||
path: "/system/dept/index",
|
||
name: "SystemDept",
|
||
meta: {
|
||
icon: "ri:git-branch-line",
|
||
title: "menus.hsDept",
|
||
roles: ["admin"]
|
||
}
|
||
},
|
||
{
|
||
path: "/system/job/index",
|
||
name: "SystemJob",
|
||
meta: {
|
||
icon: "ri:account-circle-fill",
|
||
title: "menus.hsDept",
|
||
roles: ["admin"]
|
||
}
|
||
}
|
||
]
|
||
};
|
||
|
||
const systemMonitorRouter = {
|
||
path: "/monitor",
|
||
meta: {
|
||
icon: "ep:monitor",
|
||
title: "menus.hssysMonitor",
|
||
rank: monitor
|
||
},
|
||
children: [
|
||
{
|
||
path: "/monitor/generator",
|
||
component: "monitor/generator/index",
|
||
name: "Generator",
|
||
meta: {
|
||
icon: "ri:user-voice-line",
|
||
title: "menus.hsGenerator",
|
||
roles: ["admin"]
|
||
}
|
||
},
|
||
{
|
||
path: "/monitor/online-user",
|
||
component: "monitor/online/index",
|
||
name: "OnlineUser",
|
||
meta: {
|
||
icon: "ri:user-voice-line",
|
||
title: "menus.hsOnlineUser",
|
||
roles: ["admin"]
|
||
}
|
||
},
|
||
{
|
||
path: "/monitor/login-logs",
|
||
component: "monitor/logs/login/index",
|
||
name: "LoginLog",
|
||
meta: {
|
||
icon: "ri:window-line",
|
||
title: "menus.hsLoginLog",
|
||
roles: ["admin"]
|
||
}
|
||
},
|
||
{
|
||
path: "/monitor/operation-logs",
|
||
component: "monitor/logs/operation/index",
|
||
name: "OperationLog",
|
||
meta: {
|
||
icon: "ri:history-fill",
|
||
title: "menus.hsOperationLog",
|
||
roles: ["admin"]
|
||
}
|
||
},
|
||
{
|
||
path: "/monitor/system-logs",
|
||
component: "monitor/logs/system/index",
|
||
name: "SystemLog",
|
||
meta: {
|
||
icon: "ri:file-search-line",
|
||
title: "menus.hsSystemLog",
|
||
roles: ["admin"]
|
||
}
|
||
}
|
||
]
|
||
};
|
||
|
||
const permissionRouter = {
|
||
path: "/permission",
|
||
meta: {
|
||
title: "menus.permission",
|
||
icon: "ep:lollipop",
|
||
rank: 10
|
||
},
|
||
children: [
|
||
{
|
||
path: "/editor/index",
|
||
name: "EditorPage",
|
||
meta: {
|
||
title: "Editor",
|
||
roles: ["admin", "common"]
|
||
}
|
||
},
|
||
// query 传参模式
|
||
{
|
||
path: "/monitor/generator/query-detail",
|
||
name: "TabQueryDetail",
|
||
meta: {
|
||
// 不在menu菜单中显示
|
||
showLink: false,
|
||
activePath: "/monitor/generator/index",
|
||
roles: ["admin", "common"]
|
||
}
|
||
},
|
||
// query 传参模式
|
||
{
|
||
path: "/monitor/generator/preview",
|
||
name: "TabQueryPreview",
|
||
meta: {
|
||
// 不在menu菜单中显示
|
||
showLink: false,
|
||
activePath: "/monitor/generator/index",
|
||
roles: ["admin", "common"]
|
||
}
|
||
},
|
||
{
|
||
path: "/permission/page/index",
|
||
name: "PermissionPage",
|
||
meta: {
|
||
title: "menus.permissionPage",
|
||
roles: ["admin", "common"]
|
||
}
|
||
},
|
||
{
|
||
path: "/permission/button/index",
|
||
name: "PermissionButton",
|
||
meta: {
|
||
title: "menus.permissionButton",
|
||
roles: ["admin", "common"],
|
||
auths: [
|
||
"permission:btn:add",
|
||
"permission:btn:edit",
|
||
"permission:btn:delete"
|
||
]
|
||
}
|
||
}
|
||
]
|
||
};
|
||
|
||
export default defineFakeRoute([
|
||
{
|
||
url: "/get-async-routes",
|
||
method: "get",
|
||
response: () => {
|
||
return {
|
||
success: true,
|
||
data: [systemManagementRouter, systemMonitorRouter, permissionRouter]
|
||
};
|
||
}
|
||
}
|
||
]);
|