fix: 登录异常

This commit is contained in:
骑着蜗牛追导弹 2024-11-12 20:32:37 +08:00
parent b8c5d4e325
commit 45515d9468
3 changed files with 6 additions and 19 deletions

View File

@ -1,7 +1,7 @@
import { find, assign } from 'lodash' import { assign } from 'lodash'
const users = [ const users = [
{ username: 'admin', password: '123456', uuid: 'admin-uuid', name: 'Admin' }, { username: 'admin', password: 'admin', uuid: 'admin-uuid', name: 'Admin' },
{ username: 'editor', password: 'editor', uuid: 'editor-uuid', name: 'Editor' }, { username: 'editor', password: 'editor', uuid: 'editor-uuid', name: 'Editor' },
{ username: 'user1', password: 'user1', uuid: 'user1-uuid', name: 'User1' } { username: 'user1', password: 'user1', uuid: 'user1-uuid', name: 'User1' }
] ]
@ -12,20 +12,7 @@ export default ({ service, request, serviceForMock, requestForMock, mock, faker,
* @param {Object} data 登录携带的信息 * @param {Object} data 登录携带的信息
*/ */
SYS_USER_LOGIN (data = {}) { SYS_USER_LOGIN (data = {}) {
// 模拟数据 const currentUser = users.find(f => f.username === data.username)
mock return assign({}, currentUser, { token: faker.random.uuid() })
.onAny('/login')
.reply(config => {
const user = find(users, tools.parse(config.data))
return user
? tools.responseSuccess(assign({}, user, { token: faker.random.uuid() }))
: tools.responseError({}, '账号或密码不正确')
})
// 接口请求
return requestForMock({
url: '/login',
method: 'post',
data
})
} }
}) })

View File

@ -41,5 +41,5 @@ export const menuAside = supplementPath([
// ] // ]
// } // }
{ path: '/resolveRecord', title: '解析记录', icon: 'fa-solid fa-compass' }, { path: '/resolveRecord', title: '解析记录', icon: 'fa-solid fa-compass' },
{ path: '/versionRecord', title: '版本记录', icon: 'fa-solid fa-compass' }, { path: '/versionRecord', title: '版本记录', icon: 'fa-solid fa-compass' }
]) ])

View File

@ -95,7 +95,7 @@ export default {
// //
formLogin: { formLogin: {
username: 'admin', username: 'admin',
password: '123456' password: 'admin'
}, },
// //
rules: { rules: {