From ad38d93f88967e7fb4c15d6fa723743dd5f1894c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Sun, 22 Jul 2018 19:10:58 +0800 Subject: [PATCH] Optimization: use state to control rendering time --- .gitignore | 2 ++ src/pages/Dashboard/Analysis.js | 12 +++++++++--- src/pages/layouts/LoadingPage.js | 4 +--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 4d66d865..363794d7 100755 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ functions/mock .umi .umi-production +# screenshot +screenshot \ No newline at end of file diff --git a/src/pages/Dashboard/Analysis.js b/src/pages/Dashboard/Analysis.js index fa4dd1bf..c113d340 100644 --- a/src/pages/Dashboard/Analysis.js +++ b/src/pages/Dashboard/Analysis.js @@ -61,6 +61,7 @@ class Analysis extends Component { this.state = { salesType: 'all', currentTabKey: '', + loading: true, rangePickerValue: getTimeDistance('year'), }; } @@ -77,6 +78,11 @@ class Analysis extends Component { dispatch({ type: 'chart/fetch', }); + setTimeout(() => { + this.setState({ + loading: false, + }); + }, 1000); }); } @@ -137,8 +143,8 @@ class Analysis extends Component { } render() { - const { rangePickerValue, salesType, currentTabKey } = this.state; - const { chart, loading } = this.props; + const { rangePickerValue, salesType, loading: propsLoding, currentTabKey } = this.state; + const { chart, loading: stateLoading } = this.props; const { visitData, visitData2, @@ -150,7 +156,7 @@ class Analysis extends Component { salesTypeDataOnline, salesTypeDataOffline, } = chart; - + const loading = propsLoding || stateLoading; const salesPieData = salesType === 'all' ? salesTypeData diff --git a/src/pages/layouts/LoadingPage.js b/src/pages/layouts/LoadingPage.js index e104ff2c..4a96dfc1 100644 --- a/src/pages/layouts/LoadingPage.js +++ b/src/pages/layouts/LoadingPage.js @@ -31,9 +31,7 @@ function formatter(data, parentPath = '', parentAuthority, parentName) { return result; }); } -/** - * 根据菜单取得重定向地址. - */ +// get meun map data const MenuData = formatter(routerConfig[1].routes); class LoadingPage extends PureComponent { -- GitLab