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