You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
153 lines
3.6 KiB
153 lines
3.6 KiB
1 year ago
|
|
||
|
const tokens = {
|
||
|
admin: {
|
||
|
token: 'admin-token'
|
||
|
},
|
||
|
editor: {
|
||
|
token: 'editor-token'
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const users = {
|
||
|
'admin-token': {
|
||
|
roles: ['admin'],
|
||
|
introduction: 'I am a super administrator',
|
||
|
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
|
||
|
name: 'Super Admin'
|
||
|
},
|
||
|
'editor-token': {
|
||
|
roles: ['editor'],
|
||
|
introduction: 'I am an editor',
|
||
|
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
|
||
|
name: 'Normal Editor'
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default [
|
||
|
// user login
|
||
|
{
|
||
|
url: '/vue-element-admin/user/login',
|
||
|
type: 'post',
|
||
|
response: config => {
|
||
|
const { username } = config.body
|
||
|
const token = tokens[username]
|
||
|
|
||
|
// mock error
|
||
|
if (!token) {
|
||
|
return {
|
||
|
code: 60204,
|
||
|
message: 'Account and password are incorrect.'
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
code: 20000,
|
||
|
data: token
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
|
||
|
// get user info
|
||
|
{
|
||
|
url: '/vue-element-admin/user/info\.*',
|
||
|
type: 'get',
|
||
|
response: config => {
|
||
|
const { token } = config.query
|
||
|
const info = users[token]
|
||
|
|
||
|
// mock error
|
||
|
if (!info) {
|
||
|
return {
|
||
|
code: 50008,
|
||
|
message: 'Login failed, unable to get user details.'
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
code: 20000,
|
||
|
data: info
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
|
||
|
// user logout
|
||
|
{
|
||
|
url: '/vue-element-admin/user/logout',
|
||
|
type: 'post',
|
||
|
response: _ => {
|
||
|
return {
|
||
|
code: 20000,
|
||
|
data: 'success'
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
url: '/vue-element-admin/getMenu',
|
||
|
type: 'get',
|
||
|
response: _ => {
|
||
|
return {
|
||
|
"code": 20000,
|
||
|
"data": {
|
||
|
"menuList": [
|
||
|
{
|
||
|
'create_time':'2018-03-16 11:33:00',
|
||
|
"menu_type": "M",
|
||
|
"path":'/projectManagement',
|
||
|
"component": "Layout",
|
||
|
"children": [
|
||
|
{
|
||
|
"create_time": "2018-03-16 11:33:00",
|
||
|
"menu_type": "C",
|
||
|
"children": [],
|
||
|
"parent_id": 1,
|
||
|
"menu_name": "客户管理",
|
||
|
"icon": "#",
|
||
|
"perms": "customer:index",
|
||
|
"order_num": 1,
|
||
|
"menu_id": 4,
|
||
|
"url": "/customer/index",
|
||
|
"path":'index',
|
||
|
"name": 'customer',
|
||
|
"component": "customer/index",
|
||
|
// "roles":"abpvnext_master.Customer"
|
||
|
"roles":"AbpIdentity.Users"
|
||
|
},
|
||
|
{
|
||
|
"create_time": "2018-03-16 11:33:00",
|
||
|
"menu_type": "C",
|
||
|
"children": [],
|
||
|
"parent_id": 1,
|
||
|
"menu_name": "合同管理",
|
||
|
"icon": "#",
|
||
|
"perms": "customer:contract",
|
||
|
"order_num": 1,
|
||
|
"menu_id": 4,
|
||
|
"url": "/customer/contract",
|
||
|
"path": 'contract',
|
||
|
"name": 'contract',
|
||
|
"component": "customer/contract",
|
||
|
// "roles": "abpvnext_master.Contract, abpvnext_master.Subject"
|
||
|
"roles":"AbpIdentity.Roles,AbpIdentity.Users"
|
||
|
}
|
||
|
],
|
||
|
"parent_id": 0,
|
||
|
"menu_name": "系统管理",
|
||
|
"icon": "job",
|
||
|
"perms": "customer:index",
|
||
|
"order_num": 2,
|
||
|
"menu_id": 1,
|
||
|
"url": "#",
|
||
|
}
|
||
|
],
|
||
|
"user": {
|
||
|
"login_name": "admin",
|
||
|
"user_id": 1,
|
||
|
"user_name": "管理员",
|
||
|
"dept_id": 1
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
]
|