diff --git a/.eslintrc b/.eslintrc index 5cd1493..4d3da51 100644 --- a/.eslintrc +++ b/.eslintrc @@ -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": { diff --git a/src/models/dashboard.js b/src/models/dashboard.js index b9adfe1..0541b25 100644 --- a/src/models/dashboard.js +++ b/src/models/dashboard.js @@ -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, } }) diff --git a/src/models/users.js b/src/models/users.js index 4d432c1..9bb5264 100644 --- a/src/models/users.js +++ b/src/models/users.js @@ -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({ diff --git a/src/router.js b/src/router.js index a8ff082..d9fe60f 100644 --- a/src/router.js +++ b/src/router.js @@ -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 = [