2020-09-28 20:19:10 +08:00
|
|
|
import { resultSuccess } from '../_util';
|
|
|
|
import { MockMethod } from 'vite-plugin-mock';
|
|
|
|
|
|
|
|
const dashboardRoute = {
|
2020-11-09 01:08:43 +08:00
|
|
|
path: '/dashboard',
|
|
|
|
name: 'Dashboard',
|
|
|
|
component: 'PAGE_LAYOUT',
|
|
|
|
redirect: '/dashboard/welcome',
|
|
|
|
meta: {
|
|
|
|
icon: 'ant-design:home-outlined',
|
|
|
|
title: 'Dashboard',
|
2020-09-28 20:19:10 +08:00
|
|
|
},
|
2020-11-09 01:08:43 +08:00
|
|
|
children: [
|
2020-09-28 20:19:10 +08:00
|
|
|
{
|
|
|
|
path: '/welcome',
|
|
|
|
name: 'Welcome',
|
2020-11-08 23:13:47 +08:00
|
|
|
component: '/dashboard/welcome/index',
|
2020-09-28 20:19:10 +08:00
|
|
|
meta: {
|
|
|
|
title: '欢迎页',
|
|
|
|
affix: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
const frontRoute = {
|
|
|
|
path: '/front',
|
|
|
|
name: 'PermissionFrontDemo',
|
|
|
|
meta: {
|
|
|
|
title: '基于前端权限',
|
|
|
|
},
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'page',
|
2020-11-08 23:13:47 +08:00
|
|
|
component: '/demo/permission/front/index',
|
2020-09-28 20:19:10 +08:00
|
|
|
meta: {
|
|
|
|
title: '页面权限',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'btn',
|
2020-11-08 23:13:47 +08:00
|
|
|
component: '/demo/permission/front/Btn',
|
2020-09-28 20:19:10 +08:00
|
|
|
meta: {
|
|
|
|
title: '按钮权限',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'auth-pageA',
|
2020-11-08 23:13:47 +08:00
|
|
|
component: '/demo/permission/front/AuthPageA',
|
2020-09-28 20:19:10 +08:00
|
|
|
meta: {
|
|
|
|
title: '权限测试页A',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'auth-pageB',
|
2020-11-08 23:13:47 +08:00
|
|
|
component: '/demo/permission/front/AuthPageB',
|
2020-09-28 20:19:10 +08:00
|
|
|
meta: {
|
|
|
|
title: '权限测试页B',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
const backRoute = {
|
|
|
|
path: '/back',
|
|
|
|
name: 'PermissionBackDemo',
|
|
|
|
meta: {
|
|
|
|
title: '基于后台权限',
|
|
|
|
},
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'page',
|
2020-11-08 23:13:47 +08:00
|
|
|
component: '/demo/permission/back/index',
|
2020-09-28 20:19:10 +08:00
|
|
|
meta: {
|
|
|
|
title: '页面权限',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'btn',
|
2020-11-08 23:13:47 +08:00
|
|
|
component: '/demo/permission/back/Btn',
|
2020-09-28 20:19:10 +08:00
|
|
|
meta: {
|
|
|
|
title: '按钮权限',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
const authRoute = {
|
2020-11-09 01:08:43 +08:00
|
|
|
path: '/permission',
|
|
|
|
name: 'Permission',
|
|
|
|
component: 'PAGE_LAYOUT',
|
|
|
|
redirect: '/permission/front/page',
|
|
|
|
meta: {
|
|
|
|
icon: 'ant-design:home-outlined',
|
|
|
|
title: '权限管理',
|
2020-09-28 20:19:10 +08:00
|
|
|
},
|
2020-11-09 01:08:43 +08:00
|
|
|
children: [frontRoute, backRoute],
|
2020-09-28 20:19:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const authRoute1 = {
|
2020-11-09 01:08:43 +08:00
|
|
|
path: '/permission',
|
|
|
|
name: 'Permission',
|
|
|
|
component: 'PAGE_LAYOUT',
|
|
|
|
redirect: '/permission/front/page',
|
|
|
|
meta: {
|
|
|
|
icon: 'ant-design:home-outlined',
|
|
|
|
title: '权限管理',
|
2020-09-28 20:19:10 +08:00
|
|
|
},
|
2020-11-09 01:08:43 +08:00
|
|
|
children: [backRoute],
|
2020-09-28 20:19:10 +08:00
|
|
|
};
|
|
|
|
export default [
|
|
|
|
{
|
|
|
|
url: '/api/getMenuListById',
|
|
|
|
timeout: 1000,
|
|
|
|
method: 'get',
|
|
|
|
response: ({ query }) => {
|
|
|
|
const { id } = query;
|
|
|
|
if (!id || id === '1') {
|
|
|
|
return resultSuccess([dashboardRoute, authRoute]);
|
|
|
|
}
|
|
|
|
if (id === '2') {
|
|
|
|
return resultSuccess([dashboardRoute, authRoute1]);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
] as MockMethod[];
|