ai-vue3-admin/mock/login.js

76 lines
2.1 KiB
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.

/*
*
*   ┏┓   ┏┓+ +
*  ┏┛┻━━━┛┻┓ + +
*  ┃       ┃
*  ┃   ━   ┃ ++ + + +
* ████━████ ┃+
*  ┃       ┃ +
*  ┃   ┻   ┃
*  ┃       ┃ + +
*  ┗━┓   ┏━┛
*    ┃   ┃
*    ┃   ┃ + + + +
*    ┃   ┃
*    ┃   ┃ + 神兽保佑
*    ┃   ┃ 代码无bug
*    ┃   ┃  +
*    ┃    ┗━━━┓ + +
*    ┃        ┣┓
*    ┃        ┏┛
*    ┗┓┓┏━┳┓┏┛ + + + +
*     ┃┫┫ ┃┫┫
*     ┗┻┛ ┗┻┛+ + + +
*
*
* @Descripttion:
* @version:
* @Date: 2021-04-20 11:06:21
* @LastEditors: huzhushan@126.com
* @LastEditTime: 2021-07-26 13:06:50
* @Author: huzhushan@126.com
* @HomePage: https://huzhushan.gitee.io/vue3-element-admin
* @Github: https://github.com/huzhushan/vue3-element-admin
* @Donate: https://huzhushan.gitee.io/vue3-element-admin/donate/
*/
export default [
{
url: '/api/login',
method: 'post',
timeout: 1000,
statusCode: 200,
response: ({ body }) => {
// 响应内容
return +body.password === 123456
? {
code: 200,
message: '登录成功',
data: {
token: '@word(50, 100)', // @word()是mockjs的语法
refresh_token: '@word(50, 100)', // refresh_token是用来重新生成token的
},
}
: {
code: 400,
message: '密码错误请输入123456',
}
},
},
{
url: '/api/userinfo',
method: 'get',
timeout: 100,
response: {
code: 200,
message: '获取用户信息成功',
data: {
id: 1,
name: 'zhangsan',
'role|1': ['admin', 'visitor'], // 随机返回一个角色admin或visitor
avatar: "@image('48x48', '#fb0a2a')",
},
},
},
]