2019-03-17 13:05:46 +00:00
|
|
|
import Mock from 'mockjs'
|
2019-03-18 04:32:23 +00:00
|
|
|
import { deepClone } from '../../src/utils/index.js'
|
|
|
|
import { asyncRoutes, constantRoutes } from './routes.js'
|
2019-03-17 13:05:46 +00:00
|
|
|
|
2019-03-18 04:32:23 +00:00
|
|
|
const routes = deepClone([...constantRoutes, ...asyncRoutes])
|
2019-03-17 13:05:46 +00:00
|
|
|
|
|
|
|
const roles = [
|
|
|
|
{
|
|
|
|
key: 'admin',
|
|
|
|
name: 'admin',
|
|
|
|
description: 'Super Administrator. Have access to view all pages.',
|
2019-03-18 04:32:23 +00:00
|
|
|
routes: routes
|
2019-03-17 13:05:46 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'editor',
|
|
|
|
name: 'editor',
|
|
|
|
description: 'Normal Editor. Can see all pages except permission page',
|
2019-03-18 04:32:23 +00:00
|
|
|
routes: routes.filter(i => i.path !== '/permission')// just a mock
|
2019-03-17 13:05:46 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'visitor',
|
|
|
|
name: 'visitor',
|
|
|
|
description: 'Just a visitor. Can only see the home page and the document page',
|
|
|
|
routes: [{
|
|
|
|
path: '',
|
|
|
|
redirect: 'dashboard',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'dashboard',
|
|
|
|
name: 'Dashboard',
|
|
|
|
meta: { title: 'dashboard', icon: 'dashboard' }
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2019-03-18 07:51:48 +00:00
|
|
|
export default [
|
2019-03-20 03:00:54 +00:00
|
|
|
// mock get all routes form server
|
2019-03-18 07:51:48 +00:00
|
|
|
{
|
|
|
|
url: '/routes',
|
|
|
|
type: 'get',
|
2019-03-20 03:00:54 +00:00
|
|
|
response: _ => {
|
|
|
|
return {
|
|
|
|
code: 20000,
|
|
|
|
data: routes
|
|
|
|
}
|
|
|
|
}
|
2019-03-17 13:05:46 +00:00
|
|
|
},
|
2019-03-20 03:00:54 +00:00
|
|
|
|
|
|
|
// mock get all roles form server
|
2019-03-18 07:51:48 +00:00
|
|
|
{
|
|
|
|
url: '/roles',
|
|
|
|
type: 'get',
|
2019-03-20 03:00:54 +00:00
|
|
|
response: _ => {
|
|
|
|
return {
|
|
|
|
code: 20000,
|
|
|
|
data: roles
|
|
|
|
}
|
|
|
|
}
|
2019-03-17 13:05:46 +00:00
|
|
|
},
|
2019-03-20 03:00:54 +00:00
|
|
|
|
|
|
|
// add role
|
2019-03-18 07:51:48 +00:00
|
|
|
{
|
2019-03-20 03:00:54 +00:00
|
|
|
url: '/role',
|
2019-03-18 07:51:48 +00:00
|
|
|
type: 'post',
|
2019-03-20 03:00:54 +00:00
|
|
|
response: {
|
|
|
|
code: 20000,
|
|
|
|
data: {
|
|
|
|
key: Mock.mock('@integer(300, 5000)')
|
|
|
|
}
|
|
|
|
}
|
2019-03-17 13:05:46 +00:00
|
|
|
},
|
2019-03-20 03:00:54 +00:00
|
|
|
|
|
|
|
// update role
|
2019-03-18 07:51:48 +00:00
|
|
|
{
|
2019-03-20 03:00:54 +00:00
|
|
|
url: '/role/[A-Za-z0-9]',
|
2019-03-18 07:51:48 +00:00
|
|
|
type: 'put',
|
|
|
|
response: {
|
2019-03-20 03:00:54 +00:00
|
|
|
code: 20000,
|
|
|
|
data: {
|
|
|
|
status: 'success'
|
|
|
|
}
|
2019-03-17 13:05:46 +00:00
|
|
|
}
|
|
|
|
},
|
2019-03-20 03:00:54 +00:00
|
|
|
|
|
|
|
// delete role
|
2019-03-18 07:51:48 +00:00
|
|
|
{
|
2019-03-20 03:00:54 +00:00
|
|
|
url: '/role/[A-Za-z0-9]',
|
2019-03-18 07:51:48 +00:00
|
|
|
type: 'delete',
|
|
|
|
response: {
|
2019-03-20 03:00:54 +00:00
|
|
|
code: 20000,
|
|
|
|
data: {
|
|
|
|
status: 'success'
|
|
|
|
}
|
2019-03-17 13:05:46 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-18 07:51:48 +00:00
|
|
|
]
|