diff --git a/.webpackrc.js b/.webpackrc.js
index 4d405e5f6fe7e4506b4f15c9475518a4da93edb1..2722109c41b72234910de0be221d4584411e4af2 100755
--- a/.webpackrc.js
+++ b/.webpackrc.js
@@ -28,4 +28,23 @@ export default {
publicPath: '/',
disableDynamicImport: true,
hash: true,
+ cssLoaderOptions: {
+ modules: true,
+ getLocalIdent: (context, localIdentName, localName) => {
+ if (context.resourcePath.includes('node_modules')) {
+ return localName;
+ }
+
+ let antdProPath = context.resourcePath.match(/src(.*)/)[1];
+ if (context.resourcePath.includes('components')) {
+ antdProPath = antdProPath.replace('components/', '');
+ }
+ const arr = antdProPath
+ .split('/')
+ .map(a => a.replace(/([A-Z])/g, '-$1'))
+ .map(a => a.toLowerCase());
+ arr.pop();
+ return `antd-pro${arr.join('-')}-${localName}`.replace('--', '-');
+ },
+ },
};
diff --git a/src/components/Charts/Bar/index.js b/src/components/Charts/Bar/index.js
index c91e6701231fc5ff9cb1465aa8b13a21a9f42cc1..ee188f1bc1294e6bc3b29935c114f8f5c5f6dd28 100644
--- a/src/components/Charts/Bar/index.js
+++ b/src/components/Charts/Bar/index.js
@@ -25,27 +25,25 @@ class Bar extends Component {
if (!this.node) {
return;
}
- requestAnimationFrame(() => {
- const canvasWidth = this.node.parentNode.clientWidth;
- const { data = [], autoLabel = true } = this.props;
- if (!autoLabel) {
- return;
- }
- const minWidth = data.length * 30;
- const { autoHideXLabels } = this.state;
+ const canvasWidth = this.node.parentNode.clientWidth;
+ const { data = [], autoLabel = true } = this.props;
+ if (!autoLabel) {
+ return;
+ }
+ const minWidth = data.length * 30;
+ const { autoHideXLabels } = this.state;
- if (canvasWidth <= minWidth) {
- if (!autoHideXLabels) {
- this.setState({
- autoHideXLabels: true,
- });
- }
- } else if (autoHideXLabels) {
+ if (canvasWidth <= minWidth) {
+ if (!autoHideXLabels) {
this.setState({
- autoHideXLabels: false,
+ autoHideXLabels: true,
});
}
- });
+ } else if (autoHideXLabels) {
+ this.setState({
+ autoHideXLabels: false,
+ });
+ }
}
handleRoot = n => {
diff --git a/src/components/Charts/ChartCard/index.js b/src/components/Charts/ChartCard/index.js
index c3ee1865eebea037cdd7302d00d4f93f9d56af33..dbb6efbc420a79b851f493c2fb8b3111787e7cb1 100644
--- a/src/components/Charts/ChartCard/index.js
+++ b/src/components/Charts/ChartCard/index.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { Card, Spin } from 'antd';
+import { Card } from 'antd';
import classNames from 'classnames';
import styles from './index.less';
@@ -19,59 +19,77 @@ const renderTotal = total => {
return totalDom;
};
-const ChartCard = ({
- loading = false,
- contentHeight,
- title,
- avatar,
- action,
- total,
- footer,
- children,
- ...rest
-}) => {
- const content = (
-
-
-
{avatar}
-
-
- {title}
- {action}
-
- {renderTotal(total)}
-
-
- {children && (
-
- )}
- {footer && (
+class ChartCard extends React.PureComponent {
+ state = {
+ loading: true,
+ };
+ componentDidMount() {
+ requestAnimationFrame(() => {
+ this.setState({
+ loading: false,
+ });
+ });
+ }
+ renderConnet = () => {
+ const { contentHeight, title, avatar, action, total, footer, children, loading } = this.props;
+ if (loading || this.state.loading) {
+ return false;
+ }
+ return (
+
- {footer}
+
{avatar}
+
+
+ {title}
+ {action}
+
+ {renderTotal(total)}
+
- )}
-
- );
-
- return (
-
- {
-
- {content}
-
- }
-
- );
-};
+ {children && (
+
+ )}
+ {footer && (
+
+ {footer}
+
+ )}
+
+ );
+ };
+ render() {
+ const {
+ loading = false,
+ contentHeight,
+ title,
+ avatar,
+ action,
+ total,
+ footer,
+ children,
+ ...rest
+ } = this.props;
+ return (
+
+ {this.renderConnet()}
+
+ );
+ }
+}
export default ChartCard;
diff --git a/src/components/Charts/Pie/index.js b/src/components/Charts/Pie/index.js
index b17dc88b4db2a0e4d8bc5827013b959f8aa4ba7c..0722077b634b68079779eefcb4a1f14650ffcfa2 100644
--- a/src/components/Charts/Pie/index.js
+++ b/src/components/Charts/Pie/index.js
@@ -19,7 +19,13 @@ export default class Pie extends Component {
};
componentDidMount() {
- window.addEventListener('resize', this.resize, { passive: true });
+ window.addEventListener(
+ 'resize',
+ () => {
+ requestAnimationFrame(() => this.resize());
+ },
+ { passive: true }
+ );
}
componentDidUpdate(preProps) {
@@ -66,24 +72,22 @@ export default class Pie extends Component {
@Bind()
@Debounce(300)
resize() {
- requestAnimationFrame(() => {
- const { hasLegend } = this.props;
- if (!hasLegend || !this.root) {
- window.removeEventListener('resize', this.resize);
- return;
- }
- if (this.root.parentNode.clientWidth <= 380) {
- if (!this.state.legendBlock) {
- this.setState({
- legendBlock: true,
- });
- }
- } else if (this.state.legendBlock) {
+ const { hasLegend } = this.props;
+ if (!hasLegend || !this.root) {
+ window.removeEventListener('resize', this.resize);
+ return;
+ }
+ if (this.root.parentNode.clientWidth <= 380) {
+ if (!this.state.legendBlock) {
this.setState({
- legendBlock: false,
+ legendBlock: true,
});
}
- });
+ } else if (this.state.legendBlock) {
+ this.setState({
+ legendBlock: false,
+ });
+ }
}
handleRoot = n => {
diff --git a/src/components/Charts/WaterWave/index.js b/src/components/Charts/WaterWave/index.js
index c1369c42081b0c4079713c9e274e3f89d40a9eca..ce4530c066b8f8814da77a2c110934267e98538a 100644
--- a/src/components/Charts/WaterWave/index.js
+++ b/src/components/Charts/WaterWave/index.js
@@ -17,7 +17,13 @@ export default class WaterWave extends PureComponent {
this.renderChart();
this.resize();
});
- window.addEventListener('resize', this.resize, { passive: true });
+ window.addEventListener(
+ 'resize',
+ () => {
+ requestAnimationFrame(() => this.resize());
+ },
+ { passive: true }
+ );
}
componentWillUnmount() {
@@ -29,15 +35,13 @@ export default class WaterWave extends PureComponent {
}
resize = () => {
- requestAnimationFrame(() => {
- if (this.root) {
- const { height } = this.props;
- const { offsetWidth } = this.root.parentNode;
- this.setState({
- radio: offsetWidth < height ? offsetWidth / height : 1,
- });
- }
- });
+ if (this.root) {
+ const { height } = this.props;
+ const { offsetWidth } = this.root.parentNode;
+ this.setState({
+ radio: offsetWidth < height ? offsetWidth / height : 1,
+ });
+ }
};
renderChart() {