This commit is contained in:
zuiidea
2017-04-01 16:46:32 +08:00
parent c2c0ce0267
commit 45d7abfbf4
4 changed files with 12 additions and 5 deletions
+1
View File
@@ -20,6 +20,7 @@
"no-eval": 0,
"react/jsx-no-bind": 0,
"no-unused-vars": [2, { "ignoreRestSiblings": true }],
"no-underscore-dangle": 0,
},
"parser": "babel-eslint",
"parserOptions": {
-1
View File
@@ -207,7 +207,6 @@ export default {
const result = yield call(queryWeather, { cityCode: myCityResult.selectCityCode })
const weather = zuimei.parseActualData(result.data.actual)
weather.city = myCityResult.selectCityName
yield put({ type: 'queryWeatherSuccess', payload: {
weather,
} })
+5 -1
View File
@@ -34,7 +34,11 @@ export default {
},
effects: {
*query ({ payload }, { call, put }) {
*query ({ payload }, { call, put, select }) {
const { app } = yield select(state => state)
if (!app.login) {
return
}
const data = yield call(query, parse(payload))
if (data) {
yield put({
+6 -3
View File
@@ -1,5 +1,5 @@
import React, { PropTypes } from 'react'
import { Router } from 'dva/router'
import { Router, routerRedux } from 'dva/router'
import App from './routes/app'
const cached = {}
@@ -11,8 +11,11 @@ const registerModel = (app, model) => {
}
const Routers = function ({ history, app }) {
const handleChildRoute = ({ location, params, routes }) => {
console.log(location, params, routes)
const handleChildRoute = ({ location }) => {
const state = app._store.getState()
if (!state.app.login && location.pathname !== '/login') {
app._store.dispatch(routerRedux.push('/login'))
}
}
const routes = [