mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-22 07:43:50 +00:00
46 lines
943 B
JavaScript
46 lines
943 B
JavaScript
import { login } from '../services/login'
|
|
import { routerRedux } from 'dva/router'
|
|
import { queryURL } from '../utils'
|
|
|
|
export default {
|
|
namespace: 'login',
|
|
state: {
|
|
loginLoading: false,
|
|
},
|
|
|
|
effects: {
|
|
*login ({
|
|
payload,
|
|
}, { put, call }) {
|
|
yield put({ type: 'showLoginLoading' })
|
|
const data = yield call(login, payload)
|
|
yield put({ type: 'hideLoginLoading' })
|
|
if (data.success) {
|
|
const from = queryURL('from')
|
|
yield put({ type: 'app/query' })
|
|
if (from) {
|
|
yield put(routerRedux.push(from))
|
|
} else {
|
|
yield put(routerRedux.push('/dashboard'))
|
|
}
|
|
} else {
|
|
throw data
|
|
}
|
|
},
|
|
},
|
|
reducers: {
|
|
showLoginLoading (state) {
|
|
return {
|
|
...state,
|
|
loginLoading: true,
|
|
}
|
|
},
|
|
hideLoginLoading (state) {
|
|
return {
|
|
...state,
|
|
loginLoading: false,
|
|
}
|
|
},
|
|
},
|
|
}
|