diff --git a/.eslintrc.js b/.eslintrc.js
index e29c1a8a6221f03d61414a04824b100e0e46a6b7..c20a185d2d289f0a3c16702e83b7c484aca02e49 100755
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -19,6 +19,7 @@ module.exports = {
'react/jsx-no-bind': [0],
'react/prop-types': [0],
'react/prefer-stateless-function': [0],
+ 'react/jsx-one-expression-per-line': [0],
'react/jsx-wrap-multilines': [
'error',
{
diff --git a/src/components/ActiveChart/index.js b/src/components/ActiveChart/index.js
index 07e29619f309072f0e6a3a1c99b0a5d12a09be36..433ea2eb8fb7ff3830640f251483125256304c2b 100644
--- a/src/components/ActiveChart/index.js
+++ b/src/components/ActiveChart/index.js
@@ -32,6 +32,7 @@ export default class ActiveChart extends Component {
componentWillUnmount() {
clearTimeout(this.timer);
}
+
loopData = () => {
this.timer = setTimeout(() => {
this.setState(
@@ -46,6 +47,7 @@ export default class ActiveChart extends Component {
);
}, 1000);
};
+
render() {
const { activeData = [] } = this.state;
diff --git a/src/components/Authorized/PromiseRender.js b/src/components/Authorized/PromiseRender.js
index db86efd68531ce096e5e58d116aef3085bcb5a88..62b24808258ad36e90a8637f5256bc2f9caaf874 100644
--- a/src/components/Authorized/PromiseRender.js
+++ b/src/components/Authorized/PromiseRender.js
@@ -5,13 +5,16 @@ export default class PromiseRender extends React.PureComponent {
state = {
component: null,
};
+
componentDidMount() {
this.setRenderComponent(this.props);
}
+
componentDidUpdate(nextProps) {
// new Props enter
this.setRenderComponent(nextProps);
}
+
// set render Component : ok or error
setRenderComponent(props) {
const ok = this.checkIsInstantiation(props.ok);
@@ -28,6 +31,7 @@ export default class PromiseRender extends React.PureComponent {
});
});
}
+
// Determine whether the incoming component has been instantiated
// AuthorizedRoute is already instantiated
// Authorized render is already instantiated, children is no instantiated
@@ -38,10 +42,11 @@ export default class PromiseRender extends React.PureComponent {
}
return () => target;
};
+
render() {
- const Component = this.state.component;
- return Component ? (
-
+ const { component } = this.state;
+ return component ? (
+
) : (
{
this.root = n;
};
@@ -112,6 +92,29 @@ export default class Pie extends Component {
});
};
+ // for window resize auto responsive legend
+ @Bind()
+ @Debounce(300)
+ resize() {
+ const { hasLegend } = this.props;
+ const { legendBlock } = this.state;
+ if (!hasLegend || !this.root) {
+ window.removeEventListener('resize', this.resize);
+ return;
+ }
+ if (this.root.parentNode.clientWidth <= 380) {
+ if (!legendBlock) {
+ this.setState({
+ legendBlock: true,
+ });
+ }
+ } else if (legendBlock) {
+ this.setState({
+ legendBlock: false,
+ });
+ }
+ }
+
render() {
const {
valueFormat,
@@ -137,9 +140,10 @@ export default class Pie extends Component {
});
const defaultColors = colors;
- let data = this.props.data || [];
- let selected = this.props.selected || true;
- let tooltip = this.props.tooltip || true;
+ let { data, selected, tooltip } = this.props;
+ data = data || [];
+ selected = selected || true;
+ tooltip = tooltip || true;
let formatColor;
const scale = {
diff --git a/src/components/CountDown/index.js b/src/components/CountDown/index.js
index 4485b6e8f10ed5655525f309487abab05d688b4e..0b1560e20c4a3142a8c851de7a7091c94fb996b5 100644
--- a/src/components/CountDown/index.js
+++ b/src/components/CountDown/index.js
@@ -23,32 +23,25 @@ const initTime = props => {
};
class CountDown extends Component {
+ timer = 0;
+
+ interval = 1000;
+
constructor(props) {
super(props);
-
const { lastTime } = initTime(props);
-
this.state = {
lastTime,
};
}
- static getDerivedStateFromProps(nextProps, preState) {
- const { lastTime } = initTime(nextProps);
- if (preState.lastTime !== lastTime) {
- return {
- lastTime,
- };
- }
- return null;
- }
-
componentDidMount() {
this.tick();
}
componentDidUpdate(prevProps) {
- if (this.props.target !== prevProps.target) {
+ const { target } = this.props;
+ if (target !== prevProps.target) {
clearTimeout(this.timer);
this.tick();
}
@@ -58,8 +51,16 @@ class CountDown extends Component {
clearTimeout(this.timer);
}
- timer = 0;
- interval = 1000;
+ static getDerivedStateFromProps(nextProps, preState) {
+ const { lastTime } = initTime(nextProps);
+ if (preState.lastTime !== lastTime) {
+ return {
+ lastTime,
+ };
+ }
+ return null;
+ }
+
// defaultFormat = time => (
//
{moment(time).format('hh:mm:ss')}
// );
@@ -76,6 +77,7 @@ class CountDown extends Component {
);
};
+
tick = () => {
const { onEnd } = this.props;
let { lastTime } = this.state;
diff --git a/src/components/EditableItem/index.js b/src/components/EditableItem/index.js
index fcda844e3f5af30970b2b8b58b4e4d6a9dcfe8c7..5b2ef0028ba92cc04039c9259e16fdac6f2f9078 100644
--- a/src/components/EditableItem/index.js
+++ b/src/components/EditableItem/index.js
@@ -3,23 +3,32 @@ import { Input, Icon } from 'antd';
import styles from './index.less';
export default class EditableItem extends PureComponent {
- state = {
- value: this.props.value,
- editable: false,
- };
+ constructor(props) {
+ super(props);
+ this.state = {
+ value: props.value,
+ editable: false,
+ };
+ }
+
handleChange = e => {
const { value } = e.target;
this.setState({ value });
};
+
check = () => {
this.setState({ editable: false });
- if (this.props.onChange) {
- this.props.onChange(this.state.value);
+ const { value } = this.state;
+ const { onChange } = this.state;
+ if (onChange) {
+ onChange(value);
}
};
+
edit = () => {
this.setState({ editable: true });
};
+
render() {
const { value, editable } = this.state;
return (
diff --git a/src/components/EditableLinkGroup/index.js b/src/components/EditableLinkGroup/index.js
index 2d0b4aa83a34921f6936c24b104d4933475c969d..ae3d93c712b8b019078fe37bd07286716349ef3f 100644
--- a/src/components/EditableLinkGroup/index.js
+++ b/src/components/EditableLinkGroup/index.js
@@ -17,6 +17,7 @@ class EditableLinkGroup extends PureComponent {
onAdd: () => {},
linkElement: 'a',
};
+
render() {
const { links, linkElement, onAdd } = this.props;
return (
diff --git a/src/components/GlobalHeader/RightContent.js b/src/components/GlobalHeader/RightContent.js
index 15511f9a93c12b602624d2803a657348897b38ee..7b4f98c684e8ef6453bac3e52e25658d8cacf995 100644
--- a/src/components/GlobalHeader/RightContent.js
+++ b/src/components/GlobalHeader/RightContent.js
@@ -38,6 +38,7 @@ export default class GlobalHeaderRight extends PureComponent {
});
return groupBy(newNotices, 'type');
}
+
render() {
const {
currentUser,
@@ -45,6 +46,7 @@ export default class GlobalHeaderRight extends PureComponent {
onNoticeVisibleChange,
onMenuClick,
onNoticeClear,
+ theme,
} = this.props;
const menu = (