2024-09-26 09:38:02 +08:00
|
|
|
|
// 模拟后端动态生成路由
|
2024-09-27 16:57:42 +08:00
|
|
|
|
import { defineFakeRoute } from 'vite-plugin-fake-server/client';
|
2024-09-26 09:38:02 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* roles:页面级别权限,这里模拟二种 "admin"、"common"
|
|
|
|
|
* admin:管理员角色
|
|
|
|
|
* common:普通角色
|
|
|
|
|
*/
|
|
|
|
|
const permissionRouter = {
|
2024-09-27 16:57:42 +08:00
|
|
|
|
path: '/permission',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.purePermission',
|
|
|
|
|
icon: 'ep:lollipop',
|
|
|
|
|
rank: 10,
|
|
|
|
|
},
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
path: '/permission/page/index',
|
|
|
|
|
name: 'PermissionPage',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.purePermissionPage',
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/permission/button/router',
|
|
|
|
|
component: 'permission/button/index',
|
|
|
|
|
name: 'PermissionButtonRouter',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.purePermissionButtonRouter',
|
|
|
|
|
auths: ['permission:btn:add', 'permission:btn:edit', 'permission:btn:delete'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/permission/button/login',
|
|
|
|
|
component: 'permission/button/perms',
|
|
|
|
|
name: 'PermissionButtonLogin',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.purePermissionButtonLogin',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const user = {
|
|
|
|
|
path: '/user',
|
|
|
|
|
meta: {
|
|
|
|
|
icon: 'ep:lollipop',
|
|
|
|
|
title: '用户',
|
|
|
|
|
rank: 1,
|
|
|
|
|
},
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
path: '/user/index',
|
|
|
|
|
meta: {
|
|
|
|
|
icon: null,
|
|
|
|
|
title: '用户index',
|
|
|
|
|
rank: 2,
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
auths: ['*', '*::*', '*::*::*', '*', '*::*', '::*::*'],
|
|
|
|
|
},
|
|
|
|
|
id: '2',
|
|
|
|
|
parentId: '1',
|
|
|
|
|
name: '用户index',
|
|
|
|
|
children: [],
|
|
|
|
|
},
|
|
|
|
|
],
|
2024-09-26 09:38:02 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 获取系统路由
|
|
|
|
|
export default defineFakeRoute([
|
2024-09-27 16:57:42 +08:00
|
|
|
|
{
|
|
|
|
|
url: '/mock/get-async-routes',
|
|
|
|
|
method: 'get',
|
|
|
|
|
response: () => {
|
|
|
|
|
return {
|
|
|
|
|
success: true,
|
|
|
|
|
data: [permissionRouter, user],
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-09-26 09:38:02 +08:00
|
|
|
|
]);
|