减少不必要的代码
Former-commit-id: 8c704c1c9e29c1f8887eb3b899977b35b8a5e4bd
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import Mock from 'mockjs'
|
||||
|
||||
const userDB = [
|
||||
{
|
||||
username: 'admin',
|
||||
password: 'admin',
|
||||
uuid: 'admin-uuid',
|
||||
name: '管理员'
|
||||
},
|
||||
{
|
||||
username: 'editor',
|
||||
password: 'editor',
|
||||
uuid: 'editor-uuid',
|
||||
name: '编辑'
|
||||
},
|
||||
{
|
||||
username: 'user1',
|
||||
password: 'user1',
|
||||
uuid: 'user1-uuid',
|
||||
name: '用户1'
|
||||
}
|
||||
]
|
||||
|
||||
Mock.mock('/login', 'post', ({url, type, body}) => {
|
||||
const bodyObj = JSON.parse(body)
|
||||
const user = userDB.find(e => e.username === bodyObj.username && e.password === bodyObj.password)
|
||||
if (user) {
|
||||
return {
|
||||
code: 0,
|
||||
msg: '登陆成功',
|
||||
data: {
|
||||
...user,
|
||||
token: 'd787syv8dys8cas80d9s0a0d8f79ads56f7s4d56f879a8as89fd980s7dg'
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
code: 401,
|
||||
msg: '用户名或密码错误'
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,8 @@
|
||||
import Mock from 'mockjs'
|
||||
|
||||
import '@/mock/login'
|
||||
|
||||
// 设置全局延时 没有延时的话有时候会检测不到数据变化 建议保留
|
||||
Mock.setup({
|
||||
timeout: '300-600'
|
||||
})
|
||||
Reference in New Issue
Block a user