mirror of
https://github.com/iczer/vue-antd-admin.git
synced 2025-10-13 20:36:59 +08:00
29 lines
896 B
JavaScript
29 lines
896 B
JavaScript
import Mock from 'mockjs'
|
||
import '@/mock/extend'
|
||
|
||
const user = Mock.mock({
|
||
name: '@ADMIN',
|
||
avatar: '@AVATAR',
|
||
address: '@CITY',
|
||
position: '@POSITION'
|
||
})
|
||
Mock.mock(`${process.env.VUE_APP_API_BASE_URL}/login`, 'post', ({body}) => {
|
||
let result = {}
|
||
const {name, password} = JSON.parse(body)
|
||
|
||
if (name !== 'admin' || password !== '888888') {
|
||
result.code = -1
|
||
result.message = '账户名或密码错误(admin/888888)'
|
||
} else {
|
||
result.code = 0
|
||
result.message = Mock.mock('@TIMEFIX').CN + ',欢迎回来'
|
||
result.data = {}
|
||
result.data.user = user
|
||
result.data.token = 'Authorization:' + Math.random()
|
||
result.data.expireAt = new Date(new Date().getTime() + 30 * 60 * 1000)
|
||
result.data.permissions = [{id: 'queryForm', operation: ['add', 'edit']}]
|
||
result.data.roles = [{id: 'admin', operation: ['add', 'edit', 'delete']}]
|
||
}
|
||
return result
|
||
})
|