2017-08-22 07:43:34 +00:00
|
|
|
import { param2Obj } from 'utils'
|
2017-05-15 09:56:45 +00:00
|
|
|
|
2017-04-18 07:09:13 +00:00
|
|
|
const userMap = {
|
|
|
|
admin: {
|
|
|
|
role: ['admin'],
|
|
|
|
token: 'admin',
|
|
|
|
introduction: '我是超级管理员',
|
2017-05-31 08:49:24 +00:00
|
|
|
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
|
2017-07-06 09:56:17 +00:00
|
|
|
name: 'Super Admin'
|
2017-04-18 07:09:13 +00:00
|
|
|
},
|
|
|
|
editor: {
|
|
|
|
role: ['editor'],
|
|
|
|
token: 'editor',
|
|
|
|
introduction: '我是编辑',
|
2017-05-31 08:49:24 +00:00
|
|
|
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
|
2017-07-06 09:56:17 +00:00
|
|
|
name: 'Normal Editor'
|
2017-04-18 07:09:13 +00:00
|
|
|
},
|
|
|
|
developer: {
|
|
|
|
role: ['develop'],
|
|
|
|
token: 'develop',
|
|
|
|
introduction: '我是开发',
|
2017-05-31 08:49:24 +00:00
|
|
|
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
|
2017-07-06 09:56:17 +00:00
|
|
|
name: '工程师小王'
|
2017-04-18 07:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
2017-04-24 06:15:42 +00:00
|
|
|
|
|
|
|
export default {
|
2017-08-22 06:26:19 +00:00
|
|
|
loginByUsername: config => {
|
2017-08-22 07:43:34 +00:00
|
|
|
const { username } = JSON.parse(config.body)
|
|
|
|
return userMap[username]
|
2017-04-24 06:15:42 +00:00
|
|
|
},
|
|
|
|
getInfo: config => {
|
2017-08-22 07:43:34 +00:00
|
|
|
const { token } = param2Obj(config.url)
|
2017-05-15 09:56:45 +00:00
|
|
|
if (userMap[token]) {
|
2017-08-22 07:43:34 +00:00
|
|
|
return userMap[token]
|
2017-05-15 09:56:45 +00:00
|
|
|
} else {
|
2017-08-22 07:43:34 +00:00
|
|
|
return Promise.reject('error')
|
2017-05-15 09:56:45 +00:00
|
|
|
}
|
2017-04-24 06:15:42 +00:00
|
|
|
},
|
2017-05-15 09:56:45 +00:00
|
|
|
logout: () => 'success'
|
2017-08-22 07:43:34 +00:00
|
|
|
}
|