diff --git a/package.json b/package.json index d445600a9705af11634f971d98536d61c84a691a..be15b815c52ad3a4dbf938ac248d7e1e89428eaf 100755 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "bizcharts-plugin-slider": "^2.0.1", "classnames": "^2.2.5", "dva": "^2.1.0", + "dva-loading": "^1.0.4", "enquire-js": "^0.1.1", "fastclick": "^1.0.6", "lodash": "^4.17.4", diff --git a/src/index.js b/src/index.js index 844b84a48e57a0e8d1fe51970718500f6e5da0a2..6da92a1c968117e29aaf675c7d1c49e56eb2fe9a 100644 --- a/src/index.js +++ b/src/index.js @@ -1,19 +1,21 @@ import '@babel/polyfill'; import dva from 'dva'; +import createHistory from 'history/createHashHistory'; +import createLoading from 'dva-loading'; import 'moment/locale/zh-cn'; import FastClick from 'fastclick'; import './rollbar'; import onError from './error'; -// import browserHistory from 'history/createBrowserHistory'; + import './index.less'; // 1. Initialize const app = dva({ - // history: browserHistory(), + history: createHistory(), onError, }); // 2. Plugins -// app.use({}); +app.use(createLoading()); // 3. Register global model app.model(require('./models/global').default); diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 2df22a33dce2401445afcaf8cd62dd70c01077b9..4caebc70cb3e4b5e7471436faa1cfc1ac81e8faa 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -220,9 +220,9 @@ class BasicLayout extends React.PureComponent { } } -export default connect(state => ({ - currentUser: state.user.currentUser, - collapsed: state.global.collapsed, - fetchingNotices: state.global.fetchingNotices, - notices: state.global.notices, +export default connect(({ user, global, loading }) => ({ + currentUser: user.currentUser, + collapsed: global.collapsed, + fetchingNotices: loading.effects['global/fetchNotices'], + notices: global.notices, }))(BasicLayout); diff --git a/src/models/activities.js b/src/models/activities.js index 262fc082a47441a4cc0e7116ac712eb324527f72..76a7d502e3565de535f3c58a5d51c79ef8647228 100644 --- a/src/models/activities.js +++ b/src/models/activities.js @@ -5,24 +5,15 @@ export default { state: { list: [], - loading: true, }, effects: { *fetchList(_, { call, put }) { - yield put({ - type: 'changeLoading', - payload: true, - }); const response = yield call(queryActivities); yield put({ type: 'saveList', payload: Array.isArray(response) ? response : [], }); - yield put({ - type: 'changeLoading', - payload: false, - }); }, }, @@ -33,11 +24,5 @@ export default { list: action.payload, }; }, - changeLoading(state, action) { - return { - ...state, - loading: action.payload, - }; - }, }, }; diff --git a/src/models/chart.js b/src/models/chart.js index 6922a7511e3c4e9f51d399b728d65a4c98be4aed..17bd30614d7b2577c5154f0bd1415a3b9e6c2b7c 100644 --- a/src/models/chart.js +++ b/src/models/chart.js @@ -19,10 +19,6 @@ export default { effects: { *fetch(_, { call, put }) { - yield put({ - type: 'changeLoading', - payload: true, - }); const response = yield call(fakeChartData); yield put({ type: 'save', @@ -45,7 +41,6 @@ export default { return { ...state, ...payload, - loading: false, }; }, clear() { @@ -62,11 +57,5 @@ export default { radarData: [], }; }, - changeLoading(state, { payload }) { - return { - ...state, - loading: payload, - }; - }, }, }; diff --git a/src/models/form.js b/src/models/form.js index afae2044f8fa95249d64c60f01f3be81d155b78a..64a1d49794b9b059564eadf7fce0bb9dbde5a8a3 100644 --- a/src/models/form.js +++ b/src/models/form.js @@ -12,50 +12,23 @@ export default { receiverName: 'Alex', amount: '500', }, - regularFormSubmitting: false, - stepFormSubmitting: false, - advancedFormSubmitting: false, }, effects: { - *submitRegularForm({ payload }, { call, put }) { - yield put({ - type: 'changeRegularFormSubmitting', - payload: true, - }); + *submitRegularForm({ payload }, { call }) { yield call(fakeSubmitForm, payload); - yield put({ - type: 'changeRegularFormSubmitting', - payload: false, - }); message.success('提交成功'); }, *submitStepForm({ payload }, { call, put }) { - yield put({ - type: 'changeStepFormSubmitting', - payload: true, - }); yield call(fakeSubmitForm, payload); yield put({ type: 'saveStepFormData', payload, }); - yield put({ - type: 'changeStepFormSubmitting', - payload: false, - }); yield put(routerRedux.push('/form/step-form/result')); }, - *submitAdvancedForm({ payload }, { call, put }) { - yield put({ - type: 'changeAdvancedFormSubmitting', - payload: true, - }); + *submitAdvancedForm({ payload }, { call }) { yield call(fakeSubmitForm, payload); - yield put({ - type: 'changeAdvancedFormSubmitting', - payload: false, - }); message.success('提交成功'); }, }, @@ -70,23 +43,5 @@ export default { }, }; }, - changeRegularFormSubmitting(state, { payload }) { - return { - ...state, - regularFormSubmitting: payload, - }; - }, - changeStepFormSubmitting(state, { payload }) { - return { - ...state, - stepFormSubmitting: payload, - }; - }, - changeAdvancedFormSubmitting(state, { payload }) { - return { - ...state, - advancedFormSubmitting: payload, - }; - }, }, }; diff --git a/src/models/global.js b/src/models/global.js index bbbee7025d035bfa6953f3c14374872a82189083..55841e16d053db3bf4c92b94ce877cd6601d4965 100644 --- a/src/models/global.js +++ b/src/models/global.js @@ -6,15 +6,10 @@ export default { state: { collapsed: false, notices: [], - fetchingNotices: false, }, effects: { *fetchNotices(_, { call, put }) { - yield put({ - type: 'changeNoticeLoading', - payload: true, - }); const data = yield call(queryNotices); yield put({ type: 'saveNotices', @@ -49,7 +44,6 @@ export default { return { ...state, notices: payload, - fetchingNotices: false, }; }, saveClearedNotices(state, { payload }) { @@ -58,12 +52,6 @@ export default { notices: state.notices.filter(item => item.type !== payload), }; }, - changeNoticeLoading(state, { payload }) { - return { - ...state, - fetchingNotices: payload, - }; - }, }, subscriptions: { diff --git a/src/models/list.js b/src/models/list.js index d047b8262cef95e1d16bd73e77f88ab3208ac98f..147eeca6e1465f52e833d7617bf5b31ff1b0ff5b 100644 --- a/src/models/list.js +++ b/src/models/list.js @@ -5,39 +5,22 @@ export default { state: { list: [], - loading: false, }, effects: { *fetch({ payload }, { call, put }) { - yield put({ - type: 'changeLoading', - payload: true, - }); const response = yield call(queryFakeList, payload); yield put({ type: 'queryList', payload: Array.isArray(response) ? response : [], }); - yield put({ - type: 'changeLoading', - payload: false, - }); }, *appendFetch({ payload }, { call, put }) { - yield put({ - type: 'changeLoading', - payload: true, - }); const response = yield call(queryFakeList, payload); yield put({ type: 'appendList', payload: Array.isArray(response) ? response : [], }); - yield put({ - type: 'changeLoading', - payload: false, - }); }, }, @@ -54,11 +37,5 @@ export default { list: state.list.concat(action.payload), }; }, - changeLoading(state, action) { - return { - ...state, - loading: action.payload, - }; - }, }, }; diff --git a/src/models/login.js b/src/models/login.js index ff45a61227534b3db704465ee596acce6f2723b5..05c1913ec173a28c77c733cdbe9b5981f6f2b044 100644 --- a/src/models/login.js +++ b/src/models/login.js @@ -10,10 +10,6 @@ export default { effects: { *login({ payload }, { call, put }) { - yield put({ - type: 'changeSubmitting', - payload: true, - }); const response = yield call(fakeAccountLogin, payload); yield put({ type: 'changeLoginStatus', @@ -50,13 +46,6 @@ export default { ...state, status: payload.status, type: payload.type, - submitting: false, - }; - }, - changeSubmitting(state, { payload }) { - return { - ...state, - submitting: payload, }; }, }, diff --git a/src/models/profile.js b/src/models/profile.js index ce36dfc60e4577f8d4ca0eb0e328495cfe0be066..7c9d01986447a096eeffbf064bae253b8b8d5905 100644 --- a/src/models/profile.js +++ b/src/models/profile.js @@ -5,43 +5,25 @@ export default { state: { basicGoods: [], - basicLoading: true, advancedOperation1: [], advancedOperation2: [], advancedOperation3: [], - advancedLoading: true, }, effects: { *fetchBasic(_, { call, put }) { - yield put({ - type: 'changeLoading', - payload: { basicLoading: true }, - }); const response = yield call(queryBasicProfile); yield put({ type: 'show', payload: response, }); - yield put({ - type: 'changeLoading', - payload: { basicLoading: false }, - }); }, *fetchAdvanced(_, { call, put }) { - yield put({ - type: 'changeLoading', - payload: { advancedLoading: true }, - }); const response = yield call(queryAdvancedProfile); yield put({ type: 'show', payload: response, }); - yield put({ - type: 'changeLoading', - payload: { advancedLoading: false }, - }); }, }, @@ -52,11 +34,5 @@ export default { ...payload, }; }, - changeLoading(state, { payload }) { - return { - ...state, - ...payload, - }; - }, }, }; diff --git a/src/models/project.js b/src/models/project.js index 4ad17d820e9621aa7658b1ab933d99d1112157d6..f68bef5302d79ae1a11b3300521f8198a9a1d957 100644 --- a/src/models/project.js +++ b/src/models/project.js @@ -5,24 +5,15 @@ export default { state: { notice: [], - loading: true, }, effects: { *fetchNotice(_, { call, put }) { - yield put({ - type: 'changeLoading', - payload: true, - }); const response = yield call(queryProjectNotice); yield put({ type: 'saveNotice', payload: Array.isArray(response) ? response : [], }); - yield put({ - type: 'changeLoading', - payload: false, - }); }, }, @@ -33,11 +24,5 @@ export default { notice: action.payload, }; }, - changeLoading(state, action) { - return { - ...state, - loading: action.payload, - }; - }, }, }; diff --git a/src/models/register.js b/src/models/register.js index 003494b7f265ab9938e0a88ce3d5bf4e84462e7c..164ccae111f01ca166fa9d5abf9645eb1087d7cf 100644 --- a/src/models/register.js +++ b/src/models/register.js @@ -9,19 +9,11 @@ export default { effects: { *submit(_, { call, put }) { - yield put({ - type: 'changeSubmitting', - payload: true, - }); const response = yield call(fakeRegister); yield put({ type: 'registerHandle', payload: response, }); - yield put({ - type: 'changeSubmitting', - payload: false, - }); }, }, @@ -32,11 +24,5 @@ export default { status: payload.status, }; }, - changeSubmitting(state, { payload }) { - return { - ...state, - submitting: payload, - }; - }, }, }; diff --git a/src/models/rule.js b/src/models/rule.js index 8b36ba3f59905395bbf70e42534ab65cdbccfe6f..9ae968f8d0204c32e02a9f9fa0cb4f8785c4c7ef 100644 --- a/src/models/rule.js +++ b/src/models/rule.js @@ -8,57 +8,30 @@ export default { list: [], pagination: {}, }, - loading: true, }, effects: { *fetch({ payload }, { call, put }) { - yield put({ - type: 'changeLoading', - payload: true, - }); const response = yield call(queryRule, payload); yield put({ type: 'save', payload: response, }); - yield put({ - type: 'changeLoading', - payload: false, - }); }, *add({ payload, callback }, { call, put }) { - yield put({ - type: 'changeLoading', - payload: true, - }); const response = yield call(addRule, payload); yield put({ type: 'save', payload: response, }); - yield put({ - type: 'changeLoading', - payload: false, - }); - if (callback) callback(); }, *remove({ payload, callback }, { call, put }) { - yield put({ - type: 'changeLoading', - payload: true, - }); const response = yield call(removeRule, payload); yield put({ type: 'save', payload: response, }); - yield put({ - type: 'changeLoading', - payload: false, - }); - if (callback) callback(); }, }, @@ -70,11 +43,5 @@ export default { data: action.payload, }; }, - changeLoading(state, action) { - return { - ...state, - loading: action.payload, - }; - }, }, }; diff --git a/src/models/user.js b/src/models/user.js index 197e3626e45970a1a2796ca11fd91fc513bec01f..b45afc3aa2655536e6d5360a64d116964decfdc1 100644 --- a/src/models/user.js +++ b/src/models/user.js @@ -5,25 +5,16 @@ export default { state: { list: [], - loading: false, currentUser: {}, }, effects: { *fetch(_, { call, put }) { - yield put({ - type: 'changeLoading', - payload: true, - }); const response = yield call(queryUsers); yield put({ type: 'save', payload: response, }); - yield put({ - type: 'changeLoading', - payload: false, - }); }, *fetchCurrent(_, { call, put }) { const response = yield call(queryCurrent); @@ -41,12 +32,6 @@ export default { list: action.payload, }; }, - changeLoading(state, action) { - return { - ...state, - loading: action.payload, - }; - }, saveCurrentUser(state, action) { return { ...state, diff --git a/src/routes/Dashboard.js b/src/routes/Dashboard.js index 8c108bcb86bbeb9af588c6fcf55deb6c3536ccc4..1e9bc820f85e5a7d100bbe5e2e7d9322fa95ed12 100644 --- a/src/routes/Dashboard.js +++ b/src/routes/Dashboard.js @@ -37,7 +37,7 @@ class Dashboard extends PureComponent { }); } render() { - const { user: { list, loading } } = this.props; + const { user: { list }, loading } = this.props; return (
@@ -95,6 +95,7 @@ class Dashboard extends PureComponent { } } -export default connect(state => ({ - user: state.user, +export default connect(({ user, loading }) => ({ + user, + loading: loading.effects['user/fetch'], }))(Dashboard); diff --git a/src/routes/Dashboard/Analysis.js b/src/routes/Dashboard/Analysis.js index 8d972ba6c73919a2cd0d1831a1674fe3d7207b5f..65d24967fa583b5127bdb6667005a6dbc47588da 100644 --- a/src/routes/Dashboard/Analysis.js +++ b/src/routes/Dashboard/Analysis.js @@ -42,8 +42,9 @@ for (let i = 0; i < 7; i += 1) { }); } -@connect(state => ({ - chart: state.chart, +@connect(({ chart, loading }) => ({ + chart, + loading: loading.effects['chart/fetch'], })) export default class Analysis extends Component { state = { @@ -113,7 +114,7 @@ export default class Analysis extends Component { render() { const { rangePickerValue, salesType, currentTabKey } = this.state; - const { chart } = this.props; + const { chart, loading } = this.props; const { visitData, visitData2, @@ -124,7 +125,6 @@ export default class Analysis extends Component { salesTypeData, salesTypeDataOnline, salesTypeDataOffline, - loading, } = chart; const salesPieData = diff --git a/src/routes/Dashboard/Monitor.js b/src/routes/Dashboard/Monitor.js index 75fdfa7684f7e1753d446bee4d669a1bd0ce2a14..7450fd9e5bfc3158d37f7f0c0fdae2ca4a331019 100644 --- a/src/routes/Dashboard/Monitor.js +++ b/src/routes/Dashboard/Monitor.js @@ -14,8 +14,9 @@ const { Secured } = Authorized; const targetTime = new Date().getTime() + 3900000; @Secured('admin') -@connect(state => ({ - monitor: state.monitor, +@connect(({ monitor, loading }) => ({ + monitor, + loading: loading.models.monitor, })) export default class Monitor extends PureComponent { componentDidMount() { @@ -25,7 +26,7 @@ export default class Monitor extends PureComponent { } render() { - const { monitor } = this.props; + const { monitor, loading } = this.props; const { tags } = monitor; return ( @@ -142,7 +143,7 @@ export default class Monitor extends PureComponent { - + ({ - project: state.project, - activities: state.activities, - chart: state.chart, +@connect(({ project, activities, chart, loading }) => ({ + project, + activities, + chart, + projectLoading: loading.effects['project/fetchNotice'], + activitiesLoading: loading.effects['activities/fetchList'], })) export default class Workplace extends PureComponent { componentDidMount() { @@ -131,8 +133,9 @@ export default class Workplace extends PureComponent { render() { const { - project: { loading: projectLoading, notice }, - activities: { loading: activitiesLoading }, + project: { notice }, + projectLoading, + activitiesLoading, chart: { radarData }, } = this.props; diff --git a/src/routes/Forms/AdvancedForm.js b/src/routes/Forms/AdvancedForm.js index 565c027fc06793830c9e263e15950e7b7be75861..e89e0761c852b696efaec7446147bfbf2b66d1f1 100644 --- a/src/routes/Forms/AdvancedForm.js +++ b/src/routes/Forms/AdvancedForm.js @@ -284,7 +284,7 @@ class AdvancedForm extends PureComponent { } } -export default connect(state => ({ - collapsed: state.global.collapsed, - submitting: state.form.advancedFormSubmitting, +export default connect(({ global, loading }) => ({ + collapsed: global.collapsed, + submitting: loading.effects['form/submitAdvancedForm'], }))(Form.create()(AdvancedForm)); diff --git a/src/routes/Forms/BasicForm.js b/src/routes/Forms/BasicForm.js index 7425fc49f2e46b261cc36c7471e0198bd4f9378d..bb1b3355d6a8846dd1ea3bed18d5788f54900164 100644 --- a/src/routes/Forms/BasicForm.js +++ b/src/routes/Forms/BasicForm.js @@ -11,8 +11,8 @@ const { Option } = Select; const { RangePicker } = DatePicker; const { TextArea } = Input; -@connect(state => ({ - submitting: state.form.regularFormSubmitting, +@connect(({ loading }) => ({ + submitting: loading.effects['form/submitRegularForm'], })) @Form.create() export default class BasicForms extends PureComponent { diff --git a/src/routes/Forms/StepForm/Step2.js b/src/routes/Forms/StepForm/Step2.js index 19f60523fab44922c81b295011a5261f64ba5e7b..8dee364fbb8d14514d0bd7512e914d73ea72b286 100644 --- a/src/routes/Forms/StepForm/Step2.js +++ b/src/routes/Forms/StepForm/Step2.js @@ -108,7 +108,7 @@ class Step2 extends React.PureComponent { } } -export default connect(({ form }) => ({ - submitting: form.stepFormSubmitting, +export default connect(({ form, loading }) => ({ + submitting: loading.effects['form/submitStepForm'], data: form.step, }))(Step2); diff --git a/src/routes/List/Applications.js b/src/routes/List/Applications.js index 21aa64060a585b8e727ca9de2fc58db2d6f6e916..83d1369ff0c31dfa952f0ac8a4a895e685390b4c 100644 --- a/src/routes/List/Applications.js +++ b/src/routes/List/Applications.js @@ -25,8 +25,9 @@ const formatWan = (val) => { /* eslint react/no-array-index-key: 0 */ @Form.create() -@connect(state => ({ - list: state.list, +@connect(({ list, loading }) => ({ + list, + loading: loading.models.list, })) export default class FilterCardList extends PureComponent { componentDidMount() { @@ -57,7 +58,7 @@ export default class FilterCardList extends PureComponent { } render() { - const { list: { list, loading }, form } = this.props; + const { list: { list }, loading, form } = this.props; const { getFieldDecorator } = form; const CardInfo = ({ activeUser, newUser }) => ( diff --git a/src/routes/List/Articles.js b/src/routes/List/Articles.js index 21551f1d358853e5952a1e3235184d0c2d8e8f7d..d0a3096e5694e8cc710481060127a58a490efbef 100644 --- a/src/routes/List/Articles.js +++ b/src/routes/List/Articles.js @@ -13,8 +13,9 @@ const FormItem = Form.Item; const pageSize = 5; @Form.create() -@connect(state => ({ - list: state.list, +@connect(({ list, loading }) => ({ + list, + loading: loading.models.list, })) export default class SearchList extends Component { componentDidMount() { @@ -38,7 +39,7 @@ export default class SearchList extends Component { } render() { - const { form, list: { list, loading } } = this.props; + const { form, list: { list }, loading } = this.props; const { getFieldDecorator } = form; const owners = [ diff --git a/src/routes/List/BasicList.js b/src/routes/List/BasicList.js index 2624e2d88d40bdf9717daea574222075dd5cf4da..d7cab41574270a6381e1ede9aa81bb255ad8e8d5 100644 --- a/src/routes/List/BasicList.js +++ b/src/routes/List/BasicList.js @@ -11,8 +11,9 @@ const RadioButton = Radio.Button; const RadioGroup = Radio.Group; const { Search } = Input; -@connect(state => ({ - list: state.list, +@connect(({ list, loading }) => ({ + list, + loading: loading.models.list, })) export default class BasicList extends PureComponent { componentDidMount() { @@ -25,7 +26,7 @@ export default class BasicList extends PureComponent { } render() { - const { list: { list, loading } } = this.props; + const { list: { list }, loading } = this.props; const Info = ({ title, value, bordered }) => (
diff --git a/src/routes/List/CardList.js b/src/routes/List/CardList.js index f3765973b7079109b97c0dc102fbf7714418e32b..9e3818ec8382b4c52fe9ce20b168c161b8bef6e6 100644 --- a/src/routes/List/CardList.js +++ b/src/routes/List/CardList.js @@ -7,8 +7,9 @@ import Ellipsis from '../../components/Ellipsis'; import styles from './CardList.less'; -@connect(state => ({ - list: state.list, +@connect(({ list, loading }) => ({ + list, + loading: loading.models.list, })) export default class CardList extends PureComponent { componentDidMount() { @@ -21,7 +22,7 @@ export default class CardList extends PureComponent { } render() { - const { list: { list, loading } } = this.props; + const { list: { list }, loading } = this.props; const content = (
diff --git a/src/routes/List/Projects.js b/src/routes/List/Projects.js index 51863bf61dbb8edfd64e426b4db9726b2c239dd8..3c0c9e1b39002e262ae1d573b6b8da61d281750d 100644 --- a/src/routes/List/Projects.js +++ b/src/routes/List/Projects.js @@ -14,8 +14,9 @@ const FormItem = Form.Item; /* eslint react/no-array-index-key: 0 */ @Form.create() -@connect(state => ({ - list: state.list, +@connect(({ list, loading }) => ({ + list, + loading: loading.models.list, })) export default class CoverCardList extends PureComponent { componentDidMount() { @@ -46,7 +47,7 @@ export default class CoverCardList extends PureComponent { } render() { - const { list: { list = [], loading }, form } = this.props; + const { list: { list = [] }, loading, form } = this.props; const { getFieldDecorator } = form; const cardList = list ? ( diff --git a/src/routes/List/TableList.js b/src/routes/List/TableList.js index 7527a5853a2559e78e1ded716f13c8ba9c7dbb43..2cc077751783007174c9f0a33391638b5f4a04af 100644 --- a/src/routes/List/TableList.js +++ b/src/routes/List/TableList.js @@ -10,8 +10,9 @@ const FormItem = Form.Item; const { Option } = Select; const getValue = obj => Object.keys(obj).map(key => obj[key]).join(','); -@connect(state => ({ - rule: state.rule, +@connect(({ rule, loading }) => ({ + rule, + loading: loading.models.rule, })) @Form.create() export default class TableList extends PureComponent { @@ -268,7 +269,7 @@ export default class TableList extends PureComponent { } render() { - const { rule: { loading: ruleLoading, data } } = this.props; + const { rule: { data }, loading } = this.props; const { selectedRows, modalVisible, addInputValue } = this.state; const menu = ( @@ -304,7 +305,7 @@ export default class TableList extends PureComponent {
({ - profile: state.profile, +@connect(({ profile, loading }) => ({ + profile, + loading: loading.effects['profile/fetchAdvanced'], })) export default class AdvancedProfile extends Component { state = { @@ -185,24 +186,24 @@ export default class AdvancedProfile extends Component { render() { const { stepDirection } = this.state; - const { profile } = this.props; - const { advancedLoading, advancedOperation1, advancedOperation2, advancedOperation3 } = profile; + const { profile, loading } = this.props; + const { advancedOperation1, advancedOperation2, advancedOperation3 } = profile; const contentList = { tab1: , tab2:
, tab3:
, diff --git a/src/routes/Profile/BasicProfile.js b/src/routes/Profile/BasicProfile.js index da59fc2c691e4b0010f5e75fa7b41aebb75a7dd1..ea006b01bf1d8461117d60635945ccace2b76160 100644 --- a/src/routes/Profile/BasicProfile.js +++ b/src/routes/Profile/BasicProfile.js @@ -32,8 +32,9 @@ const progressColumns = [{ key: 'cost', }]; -@connect(state => ({ - profile: state.profile, +@connect(({ profile, loading }) => ({ + profile, + loading: loading.effects['profile/fetchBasic'], })) export default class BasicProfile extends Component { componentDidMount() { @@ -44,8 +45,8 @@ export default class BasicProfile extends Component { } render() { - const { profile } = this.props; - const { basicGoods, basicProgress, basicLoading } = profile; + const { profile, loading } = this.props; + const { basicGoods, basicProgress } = profile; let goodsData = []; if (basicGoods.length) { let num = 0; @@ -146,7 +147,7 @@ export default class BasicProfile extends Component {
diff --git a/src/routes/User/Login.js b/src/routes/User/Login.js index 14a63bcae2de6891d21a451f14c4d54b59368516..c52f51ba50361b503f1f021c310eb5d97ee72526 100644 --- a/src/routes/User/Login.js +++ b/src/routes/User/Login.js @@ -7,8 +7,9 @@ import styles from './Login.less'; const { Tab, UserName, Password, Mobile, Captcha, Submit } = Login; -@connect(state => ({ - login: state.login, +@connect(({ login, loading }) => ({ + login, + submitting: loading.effects['login/login'], })) export default class LoginPage extends Component { state = { @@ -46,7 +47,7 @@ export default class LoginPage extends Component { } render() { - const { login } = this.props; + const { login, submitting } = this.props; const { type } = this.state; return (
@@ -79,7 +80,7 @@ export default class LoginPage extends Component { 自动登录 忘记密码
- 登录 + 登录
其他登录方式 diff --git a/src/routes/User/Register.js b/src/routes/User/Register.js index 1c3a426576b185d4fdb24bb9b997852ab19adfbf..e5662405b1ea5fdad027f45d727f77c4c7a7b235 100644 --- a/src/routes/User/Register.js +++ b/src/routes/User/Register.js @@ -20,8 +20,9 @@ const passwordProgressMap = { pool: 'exception', }; -@connect(state => ({ - register: state.register, +@connect(({ register, loading }) => ({ + register, + submitting: loading.effects['register/submit'], })) @Form.create() export default class Register extends Component { @@ -148,7 +149,7 @@ export default class Register extends Component { }; render() { - const { form, register } = this.props; + const { form, submitting } = this.props; const { getFieldDecorator } = form; const { count, prefix } = this.state; return ( @@ -270,7 +271,7 @@ export default class Register extends Component {