Commit ad38d93f authored by ้™ˆๅธ…'s avatar ้™ˆๅธ…

Optimization: use state to control rendering time

parent f3b77d43
...@@ -34,3 +34,5 @@ functions/mock ...@@ -34,3 +34,5 @@ functions/mock
.umi .umi
.umi-production .umi-production
# screenshot
screenshot
\ No newline at end of file
...@@ -61,6 +61,7 @@ class Analysis extends Component { ...@@ -61,6 +61,7 @@ class Analysis extends Component {
this.state = { this.state = {
salesType: 'all', salesType: 'all',
currentTabKey: '', currentTabKey: '',
loading: true,
rangePickerValue: getTimeDistance('year'), rangePickerValue: getTimeDistance('year'),
}; };
} }
...@@ -77,6 +78,11 @@ class Analysis extends Component { ...@@ -77,6 +78,11 @@ class Analysis extends Component {
dispatch({ dispatch({
type: 'chart/fetch', type: 'chart/fetch',
}); });
setTimeout(() => {
this.setState({
loading: false,
});
}, 1000);
}); });
} }
...@@ -137,8 +143,8 @@ class Analysis extends Component { ...@@ -137,8 +143,8 @@ class Analysis extends Component {
} }
render() { render() {
const { rangePickerValue, salesType, currentTabKey } = this.state; const { rangePickerValue, salesType, loading: propsLoding, currentTabKey } = this.state;
const { chart, loading } = this.props; const { chart, loading: stateLoading } = this.props;
const { const {
visitData, visitData,
visitData2, visitData2,
...@@ -150,7 +156,7 @@ class Analysis extends Component { ...@@ -150,7 +156,7 @@ class Analysis extends Component {
salesTypeDataOnline, salesTypeDataOnline,
salesTypeDataOffline, salesTypeDataOffline,
} = chart; } = chart;
const loading = propsLoding || stateLoading;
const salesPieData = const salesPieData =
salesType === 'all' salesType === 'all'
? salesTypeData ? salesTypeData
......
...@@ -31,9 +31,7 @@ function formatter(data, parentPath = '', parentAuthority, parentName) { ...@@ -31,9 +31,7 @@ function formatter(data, parentPath = '', parentAuthority, parentName) {
return result; return result;
}); });
} }
/** // get meun map data
* ๆ นๆฎ่œๅ•ๅ–ๅพ—้‡ๅฎšๅ‘ๅœฐๅ€.
*/
const MenuData = formatter(routerConfig[1].routes); const MenuData = formatter(routerConfig[1].routes);
class LoadingPage extends PureComponent { class LoadingPage extends PureComponent {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment