4
0
mirror of https://github.com/iczer/vue-antd-admin.git synced 2025-04-06 03:57:44 +08:00
chenghongxing 82e5955c3b feat: add auth support for axios request; 🌟
新增:axios 请求添加 auth 认证支持;
2020-07-20 13:10:03 +08:00

29 lines
677 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Mock from 'mockjs'
import '@/mock/extend'
const user = Mock.mock({
name: '@ADMIN',
avatar: '@AVATAR',
address: '@CITY',
welcome: '@WELCOME',
timeFix: '@TIMEFIX',
position: '@POSITION'
})
Mock.mock('/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()
}
return result
})