You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bililive_webapp/mock/test.ts

64 lines
1.7 KiB

4 years ago
import {MockMethod} from 'vite-plugin-mock';
import {changeEmailApi, changePwdApi, sendCodeApi} from "../src/interface";
4 years ago
const Mock = require('mockjs')
export default [
{
url: sendCodeApi,
method: 'post',
response: ({query}) => {
const result = Mock.mock({
'result': /OK|FAIL/,
4 years ago
})
if (result.result === 'OK') {
result.message = '验证码发送成功'
} else {
result.message = '验证码发送失败'
}
return result
4 years ago
},
},
{
url: changeEmailApi,
4 years ago
method: 'post',
response: ({query}) => {
const result = Mock.mock({
'result': /OK|FAIL/,
})
if (result.result === 'OK') {
result.message = '邮箱更新成功'
return result
} else {
return {
...result, ...Mock.mock({
'message': /更新失败,(邮箱不合法|邮箱已绑定|请输入正确验证码)/
})
}
}
4 years ago
},
},
{
url: changePwdApi,
method: 'post',
response: ({query}) => {
const result = Mock.mock({
'result': /OK|FAIL/,
})
if (result.result === 'OK') {
result.message = '修改密码成功'
return result
} else {
return {
...result, ...Mock.mock({
'message': /修改失败,(密码不合法)/
})
}
}
}
}
4 years ago
] as MockMethod[];