text: 
  import { routerRedux } from 'dva/router'
  import { login } from 'services/login'
  
  export default {
    namespace: 'login',
  
    state: {},
  
    effects: {
      * login ({
        payload,
      }, { put, call, select }) {
        const data = yield call(login, payload)
        localStorage.setItem('token', data.token)
        const { locationQuery } = yield select(_ => _.app)
        if (data.success) {
          const { from } = locationQuery
          yield put({ type: 'app/query' })
          if (from && from !== '/login') {
            yield put(routerRedux.push(from))
          } else {
            yield put(routerRedux.push('/dashboard'))
          }
        } else {
          throw data
        }
      },
    },
  
  }
  