From 5f5bc2f8e18066aeb1a2e543332042f79384c6ad Mon Sep 17 00:00:00 2001 From: wangyun122 Date: Tue, 5 Jun 2018 17:50:22 +0800 Subject: [PATCH 01/31] fix typo (#1611) --- src/layouts/BasicLayout.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 29a4346f..b0ae923c 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -128,7 +128,7 @@ class BasicLayout extends React.PureComponent { } return title; } - getBashRedirect = () => { + getBaseRedirect = () => { // According to the url parameter to redirect // 这里是重定向的,重定向到 url 的 redirect 参数所示地址 const urlParams = new URL(window.location.href); @@ -189,7 +189,7 @@ class BasicLayout extends React.PureComponent { match, location, } = this.props; - const bashRedirect = this.getBashRedirect(); + const bashRedirect = this.getBaseRedirect(); const layout = ( Date: Wed, 6 Jun 2018 10:51:36 +0800 Subject: [PATCH 02/31] fix #1593 (#1616) --- src/utils/utils.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index 37b6eca6..9700b31e 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -123,11 +123,10 @@ function getRenderArr(routes) { let renderArr = []; renderArr.push(routes[0]); for (let i = 1; i < routes.length; i += 1) { - let isAdd = false; - // 是否包含 - isAdd = renderArr.every(item => getRelation(item, routes[i]) === 3); // 去重 renderArr = renderArr.filter(item => getRelation(item, routes[i]) !== 1); + // 是否包含 + const isAdd = renderArr.every(item => getRelation(item, routes[i]) === 3); if (isAdd) { renderArr.push(routes[i]); } From 2553b04bdf7e10a5287d9811e2fbd145623f8027 Mon Sep 17 00:00:00 2001 From: Sean Bao Date: Mon, 4 Jun 2018 17:45:20 +0800 Subject: [PATCH 03/31] Fix children empty judgement in Description --- src/components/DescriptionList/Description.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/DescriptionList/Description.js b/src/components/DescriptionList/Description.js index e024796e..3e41c071 100644 --- a/src/components/DescriptionList/Description.js +++ b/src/components/DescriptionList/Description.js @@ -10,7 +10,8 @@ const Description = ({ term, column, className, children, ...restProps }) => { return ( {term &&
{term}
} - {children &&
{children}
} + {children !== null && children !== undefined && +
{children}
} ); }; From 7ffc34b3d4e561701a2c30ddb1fbcda18da7c5fc Mon Sep 17 00:00:00 2001 From: Mashiro Date: Mon, 11 Jun 2018 14:16:22 +0800 Subject: [PATCH 04/31] fix: add property className into interface IHeaderSearchProps --- src/components/HeaderSearch/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/HeaderSearch/index.d.ts b/src/components/HeaderSearch/index.d.ts index 3a06d758..28e56cc0 100644 --- a/src/components/HeaderSearch/index.d.ts +++ b/src/components/HeaderSearch/index.d.ts @@ -6,6 +6,7 @@ export interface IHeaderSearchProps { onChange?: (value: string) => void; onPressEnter?: (value: string) => void; style?: React.CSSProperties; + className?: string; } export default class HeaderSearch extends React.Component {} From 27a2353c93853cd88d4fdb6a3269f0a17f289a09 Mon Sep 17 00:00:00 2001 From: zbz Date: Tue, 12 Jun 2018 15:19:50 +0800 Subject: [PATCH 05/31] =?UTF-8?q?=E4=BF=AE=E6=AD=A3DELETE=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E6=96=B9=E6=B3=95request=E6=97=B6body=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=97=A0=E6=95=88=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/request.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/request.js b/src/utils/request.js index 591da964..af1aaf74 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -47,7 +47,7 @@ export default function request(url, options) { credentials: 'include', }; const newOptions = { ...defaultOptions, ...options }; - if (newOptions.method === 'POST' || newOptions.method === 'PUT') { + if (newOptions.method === 'POST' || newOptions.method === 'PUT' || newOptions.method === 'DELETE') { if (!(newOptions.body instanceof FormData)) { newOptions.headers = { Accept: 'application/json', From bcb9280cd1340888259484b47b69121d47df2152 Mon Sep 17 00:00:00 2001 From: patientayo Date: Tue, 12 Jun 2018 16:25:34 +0800 Subject: [PATCH 06/31] fix: waterwave doesn't render when precent=0 --- src/components/Charts/WaterWave/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Charts/WaterWave/index.js b/src/components/Charts/WaterWave/index.js index 5b463ad5..70938427 100644 --- a/src/components/Charts/WaterWave/index.js +++ b/src/components/Charts/WaterWave/index.js @@ -40,7 +40,7 @@ export default class WaterWave extends PureComponent { const data = percent / 100; const self = this; - if (!this.node || !data) { + if (!this.node || (data !== 0 && !data)) { return; } From 5baed891ed4b4bdba53b83b7089baf2ed80722c8 Mon Sep 17 00:00:00 2001 From: twisger Date: Fri, 8 Jun 2018 17:36:54 +0800 Subject: [PATCH 07/31] feature: consider full-width character length as 2 when calculate string length --- src/components/Ellipsis/index.d.ts | 1 + src/components/Ellipsis/index.en-US.md | 1 + src/components/Ellipsis/index.js | 46 +++++++++++++++++++++++--- src/components/Ellipsis/index.test.js | 13 ++++++++ src/components/Ellipsis/index.zh-CN.md | 1 + 5 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 src/components/Ellipsis/index.test.js diff --git a/src/components/Ellipsis/index.d.ts b/src/components/Ellipsis/index.d.ts index 4643ee76..a7673c8d 100644 --- a/src/components/Ellipsis/index.d.ts +++ b/src/components/Ellipsis/index.d.ts @@ -5,6 +5,7 @@ export interface IEllipsisProps { lines?: number; style?: React.CSSProperties; className?: string; + caculateShowLength?: boolean; } export default class Ellipsis extends React.Component {} diff --git a/src/components/Ellipsis/index.en-US.md b/src/components/Ellipsis/index.en-US.md index fa5beb64..2f34cc3f 100644 --- a/src/components/Ellipsis/index.en-US.md +++ b/src/components/Ellipsis/index.en-US.md @@ -13,3 +13,4 @@ Property | Description | Type | Default tooltip | tooltip for showing the full text content when hovering over | boolean | - length | maximum number of characters in the text before being truncated | number | - lines | maximum number of rows in the text before being truncated | number | `1` +caculateShowLength | whether consider full-width character length as 2 when calculate string length | boolean | - diff --git a/src/components/Ellipsis/index.js b/src/components/Ellipsis/index.js index 671bc453..69439fad 100644 --- a/src/components/Ellipsis/index.js +++ b/src/components/Ellipsis/index.js @@ -8,11 +8,40 @@ import styles from './index.less'; const isSupportLineClamp = document.body.style.webkitLineClamp !== undefined; -const EllipsisText = ({ text, length, tooltip, ...other }) => { +export const getStrShowLength = (str = '') => { + return str.split('').reduce((pre, cur) => { + const charCode = cur.charCodeAt(0); + if (charCode >= 0 && charCode <= 128) { + return pre + 1; + } else { + return pre + 2; + } + }, 0); +}; + +export const cutStrByShowLength = (str = '', maxLength) => { + let showLength = 0; + return str.split('').reduce((pre, cur) => { + const charCode = cur.charCodeAt(0); + if (charCode >= 0 && charCode <= 128) { + showLength += 1; + } else { + showLength += 2; + } + if (showLength <= maxLength) { + return pre + cur; + } else { + return pre; + } + }, ''); +}; + +const EllipsisText = ({ text, length, tooltip, caculateShowLength, ...other }) => { if (typeof text !== 'string') { throw new Error('Ellipsis children must be string.'); } - if (text.length <= length || length < 0) { + const textLength = caculateShowLength ? getStrShowLength(text) : text.length; + if (textLength <= length || length < 0) { return {text}; } const tail = '...'; @@ -20,7 +49,7 @@ const EllipsisText = ({ text, length, tooltip, ...other }) => { if (length - tail.length <= 0) { displayText = ''; } else { - displayText = text.slice(0, length); + displayText = caculateShowLength ? cutStrByShowLength(text, length) : text.slice(0, length); } if (tooltip) { @@ -147,7 +176,15 @@ export default class Ellipsis extends Component { render() { const { text, targetCount } = this.state; - const { children, lines, length, className, tooltip, ...restProps } = this.props; + const { + children, + lines, + length, + className, + tooltip, + caculateShowLength, + ...restProps + } = this.props; const cls = classNames(styles.ellipsis, className, { [styles.lines]: lines && !isSupportLineClamp, @@ -170,6 +207,7 @@ export default class Ellipsis extends Component { length={length} text={children || ''} tooltip={tooltip} + caculateShowLength={caculateShowLength} {...restProps} /> ); diff --git a/src/components/Ellipsis/index.test.js b/src/components/Ellipsis/index.test.js new file mode 100644 index 00000000..18772f02 --- /dev/null +++ b/src/components/Ellipsis/index.test.js @@ -0,0 +1,13 @@ +import { getStrShowLength, cutStrByShowLength } from './index.js'; + +describe('test calculateShowLength', () => { + it('get show length', () => { + expect(getStrShowLength('一二,a,')).toEqual(8); + }); + it('cut str by show length', () => { + expect(cutStrByShowLength('一二,a,', 7)).toEqual('一二,a'); + }); + it('cut str when length small', () => { + expect(cutStrByShowLength('一22三', 5)).toEqual('一22'); + }); +}); diff --git a/src/components/Ellipsis/index.zh-CN.md b/src/components/Ellipsis/index.zh-CN.md index 8fe98bb0..20157878 100644 --- a/src/components/Ellipsis/index.zh-CN.md +++ b/src/components/Ellipsis/index.zh-CN.md @@ -14,3 +14,4 @@ order: 10 tooltip | 移动到文本展示完整内容的提示 | boolean | - length | 在按照长度截取下的文本最大字符数,超过则截取省略 | number | - lines | 在按照行数截取下最大的行数,超过则截取省略 | number | `1` +caculateShowLength | 是否将全角字符的长度视为2来计算字符串长度 | boolean | - From 456d25aa605e0caa4bd4fdd5c3ee15b9c467d5e2 Mon Sep 17 00:00:00 2001 From: twisger Date: Mon, 11 Jun 2018 18:38:13 +0800 Subject: [PATCH 08/31] change api name --- src/components/Ellipsis/index.d.ts | 2 +- src/components/Ellipsis/index.en-US.md | 2 +- src/components/Ellipsis/index.js | 14 +++++++------- src/components/Ellipsis/index.test.js | 12 ++++++------ src/components/Ellipsis/index.zh-CN.md | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/Ellipsis/index.d.ts b/src/components/Ellipsis/index.d.ts index a7673c8d..9fd49f17 100644 --- a/src/components/Ellipsis/index.d.ts +++ b/src/components/Ellipsis/index.d.ts @@ -5,7 +5,7 @@ export interface IEllipsisProps { lines?: number; style?: React.CSSProperties; className?: string; - caculateShowLength?: boolean; + fullWidthRecognition?: boolean; } export default class Ellipsis extends React.Component {} diff --git a/src/components/Ellipsis/index.en-US.md b/src/components/Ellipsis/index.en-US.md index 2f34cc3f..15139cc9 100644 --- a/src/components/Ellipsis/index.en-US.md +++ b/src/components/Ellipsis/index.en-US.md @@ -13,4 +13,4 @@ Property | Description | Type | Default tooltip | tooltip for showing the full text content when hovering over | boolean | - length | maximum number of characters in the text before being truncated | number | - lines | maximum number of rows in the text before being truncated | number | `1` -caculateShowLength | whether consider full-width character length as 2 when calculate string length | boolean | - +fullWidthRecognition | whether consider full-width character length as 2 when calculate string length | boolean | - diff --git a/src/components/Ellipsis/index.js b/src/components/Ellipsis/index.js index 69439fad..4537b367 100644 --- a/src/components/Ellipsis/index.js +++ b/src/components/Ellipsis/index.js @@ -8,7 +8,7 @@ import styles from './index.less'; const isSupportLineClamp = document.body.style.webkitLineClamp !== undefined; -export const getStrShowLength = (str = '') => { +export const getStrFullLength = (str = '') => { return str.split('').reduce((pre, cur) => { const charCode = cur.charCodeAt(0); if (charCode >= 0 && charCode <= 128) { @@ -19,7 +19,7 @@ export const getStrShowLength = (str = '') => { }, 0); }; -export const cutStrByShowLength = (str = '', maxLength) => { +export const cutStrByFullLength = (str = '', maxLength) => { let showLength = 0; return str.split('').reduce((pre, cur) => { const charCode = cur.charCodeAt(0); @@ -36,11 +36,11 @@ export const cutStrByShowLength = (str = '', maxLength) => { }, ''); }; -const EllipsisText = ({ text, length, tooltip, caculateShowLength, ...other }) => { +const EllipsisText = ({ text, length, tooltip, fullWidthRecognition, ...other }) => { if (typeof text !== 'string') { throw new Error('Ellipsis children must be string.'); } - const textLength = caculateShowLength ? getStrShowLength(text) : text.length; + const textLength = fullWidthRecognition ? getStrFullLength(text) : text.length; if (textLength <= length || length < 0) { return {text}; } @@ -49,7 +49,7 @@ const EllipsisText = ({ text, length, tooltip, caculateShowLength, ...other }) = if (length - tail.length <= 0) { displayText = ''; } else { - displayText = caculateShowLength ? cutStrByShowLength(text, length) : text.slice(0, length); + displayText = fullWidthRecognition ? cutStrByFullLength(text, length) : text.slice(0, length); } if (tooltip) { @@ -182,7 +182,7 @@ export default class Ellipsis extends Component { length, className, tooltip, - caculateShowLength, + fullWidthRecognition, ...restProps } = this.props; @@ -207,7 +207,7 @@ export default class Ellipsis extends Component { length={length} text={children || ''} tooltip={tooltip} - caculateShowLength={caculateShowLength} + fullWidthRecognition={fullWidthRecognition} {...restProps} /> ); diff --git a/src/components/Ellipsis/index.test.js b/src/components/Ellipsis/index.test.js index 18772f02..ab454637 100644 --- a/src/components/Ellipsis/index.test.js +++ b/src/components/Ellipsis/index.test.js @@ -1,13 +1,13 @@ -import { getStrShowLength, cutStrByShowLength } from './index.js'; +import { getStrFullLength, cutStrByFullLength } from './index.js'; describe('test calculateShowLength', () => { - it('get show length', () => { - expect(getStrShowLength('一二,a,')).toEqual(8); + it('get full length', () => { + expect(getStrFullLength('一二,a,')).toEqual(8); }); - it('cut str by show length', () => { - expect(cutStrByShowLength('一二,a,', 7)).toEqual('一二,a'); + it('cut str by full length', () => { + expect(cutStrByFullLength('一二,a,', 7)).toEqual('一二,a'); }); it('cut str when length small', () => { - expect(cutStrByShowLength('一22三', 5)).toEqual('一22'); + expect(cutStrByFullLength('一22三', 5)).toEqual('一22'); }); }); diff --git a/src/components/Ellipsis/index.zh-CN.md b/src/components/Ellipsis/index.zh-CN.md index 20157878..f7a70ead 100644 --- a/src/components/Ellipsis/index.zh-CN.md +++ b/src/components/Ellipsis/index.zh-CN.md @@ -14,4 +14,4 @@ order: 10 tooltip | 移动到文本展示完整内容的提示 | boolean | - length | 在按照长度截取下的文本最大字符数,超过则截取省略 | number | - lines | 在按照行数截取下最大的行数,超过则截取省略 | number | `1` -caculateShowLength | 是否将全角字符的长度视为2来计算字符串长度 | boolean | - +fullWidthRecognition | 是否将全角字符的长度视为2来计算字符串长度 | boolean | - From 566d407222522eb8da0c3d027e9f14ff7d78a5b9 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 12 Jun 2018 19:35:16 +0800 Subject: [PATCH 09/31] Add deps badges --- README.md | 6 +++++- README.zh-CN.md | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3e7faae6..ea7bfaa7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,11 @@ English | [简体中文](./README.zh-CN.md) # Ant Design Pro -[![](https://img.shields.io/travis/ant-design/ant-design-pro/master.svg?style=flat-square)](https://travis-ci.org/ant-design/ant-design-pro) [![Build status](https://ci.appveyor.com/api/projects/status/67fxu2by3ibvqtat/branch/master?svg=true)](https://ci.appveyor.com/project/afc163/ant-design-pro/branch/master) [![Gitter](https://badges.gitter.im/ant-design/ant-design-pro.svg)](https://gitter.im/ant-design/ant-design-pro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) +[![](https://img.shields.io/travis/ant-design/ant-design-pro/master.svg?style=flat-square)](https://travis-ci.org/ant-design/ant-design-pro) +[![Build status](https://ci.appveyor.com/api/projects/status/67fxu2by3ibvqtat/branch/master?svg=true)](https://ci.appveyor.com/project/afc163/ant-design-pro/branch/master) +[![Dependencies](https://img.shields.io/david/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro) +[![DevDependencies](https://img.shields.io/david/dev/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro#info=devDependencies&view=list) +[![Gitter](https://badges.gitter.im/ant-design/ant-design-pro.svg)](https://gitter.im/ant-design/ant-design-pro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) An out-of-box UI solution for enterprise applications as a React boilerplate. diff --git a/README.zh-CN.md b/README.zh-CN.md index 8f24c72b..030d506c 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -2,7 +2,11 @@ # Ant Design Pro -[![](https://img.shields.io/travis/ant-design/ant-design-pro.svg?style=flat-square)](https://travis-ci.org/ant-design/ant-design-pro) [![Build status](https://ci.appveyor.com/api/projects/status/67fxu2by3ibvqtat/branch/master?svg=true)](https://ci.appveyor.com/project/afc163/ant-design-pro/branch/master) [![Gitter](https://badges.gitter.im/ant-design/ant-design-pro.svg)](https://gitter.im/ant-design/ant-design-pro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) +[![](https://img.shields.io/travis/ant-design/ant-design-pro/master.svg?style=flat-square)](https://travis-ci.org/ant-design/ant-design-pro) +[![Build status](https://ci.appveyor.com/api/projects/status/67fxu2by3ibvqtat/branch/master?svg=true)](https://ci.appveyor.com/project/afc163/ant-design-pro/branch/master) +[![Dependencies](https://img.shields.io/david/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro) +[![DevDependencies](https://img.shields.io/david/dev/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro#info=devDependencies&view=list) +[![Gitter](https://badges.gitter.im/ant-design/ant-design-pro.svg)](https://gitter.im/ant-design/ant-design-pro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 开箱即用的中台前端/设计解决方案。 From aaca87ccc7e71d6660a176e77e2299fd49ea74de Mon Sep 17 00:00:00 2001 From: yoyo837 Date: Mon, 11 Jun 2018 19:47:24 +0800 Subject: [PATCH 10/31] rc-drawer-menu is deprecated, use rc-drawer instead. Apply API change, fix iconHandle not work. --- package.json | 2 +- src/components/SiderMenu/index.js | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 0b384699..8581d966 100755 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "path-to-regexp": "^2.1.0", "prop-types": "^15.5.10", "qs": "^6.5.0", - "rc-drawer-menu": "^0.5.0", + "rc-drawer": "^1.2.0", "react": "^16.2.0", "react-container-query": "^0.9.1", "react-document-title": "^2.0.3", diff --git a/src/components/SiderMenu/index.js b/src/components/SiderMenu/index.js index a0dca978..a23459d5 100644 --- a/src/components/SiderMenu/index.js +++ b/src/components/SiderMenu/index.js @@ -1,19 +1,21 @@ -import 'rc-drawer-menu/assets/index.css'; +import 'rc-drawer/assets/index.css'; import React from 'react'; -import DrawerMenu from 'rc-drawer-menu'; +import DrawerMenu from 'rc-drawer'; import SiderMenu from './SiderMenu'; const SiderMenuWrapper = props => props.isMobile ? ( } + onHandleClick={() => { + props.onCollapse(!props.collapsed); + }} open={!props.collapsed} onMaskClick={() => { props.onCollapse(true); }} - width="256px" > From 1da5d11cb987890b93508e291d4076de751ee58d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Tue, 12 Jun 2018 20:41:28 +0800 Subject: [PATCH 11/31] upgrade deps version --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 8581d966..e35bfe5e 100755 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "bizcharts-plugin-slider": "^2.0.1", "classnames": "^2.2.5", "dva": "^2.2.3", - "dva-loading": "^1.0.4", + "dva-loading": "^2.0.3", "enquire-js": "^0.2.1", "less": "2.7.2", "lodash": "^4.17.10", @@ -43,7 +43,7 @@ "qs": "^6.5.0", "rc-drawer": "^1.2.0", "react": "^16.2.0", - "react-container-query": "^0.9.1", + "react-container-query": "^0.11.0", "react-document-title": "^2.0.3", "react-dom": "^16.2.0", "react-fittext": "^1.0.0", @@ -61,7 +61,7 @@ "eslint": "^4.14.0", "eslint-config-airbnb": "^16.0.0", "eslint-config-prettier": "^2.9.0", - "eslint-plugin-babel": "^4.0.0", + "eslint-plugin-babel": "^5.1.0", "eslint-plugin-compat": "^2.1.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.3", @@ -69,15 +69,15 @@ "eslint-plugin-react": "^7.0.1", "gh-pages": "^1.0.0", "husky": "^0.14.3", - "lint-staged": "^6.0.0", + "lint-staged": "^7.2.0", "mockjs": "^1.0.1-beta3", - "prettier": "1.11.1", + "prettier": "1.13.5", "pro-download": "^1.0.1", "redbox-react": "^1.5.0", "regenerator-runtime": "^0.11.1", "roadhog": "^2.4.1", "roadhog-api-doc": "^1.0.3", - "stylelint": "^8.4.0", + "stylelint": "^9.2.1", "stylelint-config-prettier": "^3.0.4", "stylelint-config-standard": "^18.0.0" }, From 5c2dd01e835e66e96f19b8296af62472e6411fa8 Mon Sep 17 00:00:00 2001 From: Advoster <648542313@qq.com> Date: Thu, 14 Jun 2018 00:54:01 +0800 Subject: [PATCH 12/31] Update register.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复注册表单提交的数据未添加到POST请求的Body中的问题 --- src/models/register.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/register.js b/src/models/register.js index 54c49633..57a97838 100644 --- a/src/models/register.js +++ b/src/models/register.js @@ -10,8 +10,8 @@ export default { }, effects: { - *submit(_, { call, put }) { - const response = yield call(fakeRegister); + *submit({ payload }, { call, put }) { + const response = yield call(fakeRegister, payload); yield put({ type: 'registerHandle', payload: response, From 0f9f76783af20d500b6def76afb4ef66188a439c Mon Sep 17 00:00:00 2001 From: niko <644506165@qq.com> Date: Fri, 15 Jun 2018 11:15:52 +0800 Subject: [PATCH 13/31] fix Ellipsis floor-mid to ceil-mid #1258 (#1680) --- src/components/Ellipsis/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Ellipsis/index.js b/src/components/Ellipsis/index.js index 4537b367..8306b5d8 100644 --- a/src/components/Ellipsis/index.js +++ b/src/components/Ellipsis/index.js @@ -109,7 +109,7 @@ export default class Ellipsis extends Component { // bisection const len = text.length; - const mid = Math.floor(len / 2); + const mid = Math.ceil(len / 2); const count = this.bisection(targetHeight, mid, 0, len, text, shadowNode); From 6c1b112a40782f00f9c4ad04dd914ea6808c74c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Fri, 15 Jun 2018 21:52:57 +0800 Subject: [PATCH 14/31] fix #1681 `lint-staged` no longer supports running scripts defined in package.json. --- .gitignore | 3 +-- package.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 4770ad5a..59a03667 100755 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ _roadhog-api-doc # production /dist -/vscode +/.vscode # misc .DS_Store @@ -21,4 +21,3 @@ yarn.lock package-lock.json *bak jsconfig.json -.vscode/settings.json diff --git a/package.json b/package.json index e35bfe5e..4c810773 100755 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "prettier --write", "git add" ], - "**/*.{js,jsx}": "lint-staged:js", + "**/*.{js,jsx}": "npm run lint-staged:js", "**/*.less": "stylelint --syntax less" }, "engines": { From 80dc0567a6121fc006eef1498716b96fb3fc4585 Mon Sep 17 00:00:00 2001 From: guowenfh Date: Thu, 14 Jun 2018 00:23:19 +0800 Subject: [PATCH 15/31] feature: add authority function After performing return Promise is render component --- src/components/Authorized/CheckPermissions.js | 4 ++++ src/components/Authorized/index.md | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/Authorized/CheckPermissions.js b/src/components/Authorized/CheckPermissions.js index d51e9833..8a6c9780 100644 --- a/src/components/Authorized/CheckPermissions.js +++ b/src/components/Authorized/CheckPermissions.js @@ -52,6 +52,10 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => { if (bool) { return target; } + // 函数执行后返回值是 Promise + if (isPromise(bool)) { + return ; + } return Exception; } catch (error) { throw error; diff --git a/src/components/Authorized/index.md b/src/components/Authorized/index.md index 51588bb5..f3b2f80a 100644 --- a/src/components/Authorized/index.md +++ b/src/components/Authorized/index.md @@ -25,14 +25,14 @@ order: 15 | 参数 | 说明 | 类型 | 默认值 | |----------|------------------------------------------|-------------|-------| | children | 正常渲染的元素,权限判断通过时展示 | ReactNode | - | -| authority | 准入权限/权限判断 | `string | array | Promise | (currentAuthority) => boolean` | - | +| authority | 准入权限/权限判断 | `string | array | Promise | (currentAuthority) => boolean | Promise` | - | | noMatch | 权限异常渲染元素,权限判断不通过时展示 | ReactNode | - | ### Authorized.AuthorizedRoute | 参数 | 说明 | 类型 | 默认值 | |----------|------------------------------------------|-------------|-------| -| authority | 准入权限/权限判断 | `string | array | Promise | (currentAuthority) => boolean` | - | +| authority | 准入权限/权限判断 | `string | array | Promise | (currentAuthority) => boolean | Promise` | - | | redirectPath | 权限异常时重定向的页面路由 | string | - | 其余参数与 `Route` 相同。 @@ -43,16 +43,16 @@ order: 15 | 参数 | 说明 | 类型 | 默认值 | |----------|------------------------------------------|-------------|-------| -| authority | 准入权限/权限判断 | `string | Promise | (currentAuthority) => boolean` | - | +| authority | 准入权限/权限判断 | `string | Promise | (currentAuthority) => boolean | Promise` | - | | error | 权限异常时渲染元素 | ReactNode | | ### Authorized.check -函数形式的 Authorized,用于某些不能被 HOC 包裹的组件。 `Authorized.check(authority, target, Exception)` +函数形式的 Authorized,用于某些不能被 HOC 包裹的组件。 `Authorized.check(authority, target, Exception)` 注意:传入一个 Promise 时,无论正确还是错误返回的都是一个 ReactClass。 | 参数 | 说明 | 类型 | 默认值 | |----------|------------------------------------------|-------------|-------| -| authority | 准入权限/权限判断 | `string | Promise | (currentAuthority) => boolean` | - | +| authority | 准入权限/权限判断 | `string | Promise | (currentAuthority) => boolean | Promise` | - | | target | 权限判断通过时渲染的元素 | ReactNode | - | | Exception | 权限异常时渲染元素 | ReactNode | - | From a8f818048539f4848e38b6302e9a392703aa69d3 Mon Sep 17 00:00:00 2001 From: guowenfh Date: Thu, 14 Jun 2018 00:37:41 +0800 Subject: [PATCH 16/31] fix checkPermissions if bool --- src/components/Authorized/CheckPermissions.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Authorized/CheckPermissions.js b/src/components/Authorized/CheckPermissions.js index 8a6c9780..0c3b9a4c 100644 --- a/src/components/Authorized/CheckPermissions.js +++ b/src/components/Authorized/CheckPermissions.js @@ -50,12 +50,12 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => { try { const bool = authority(currentAuthority); if (bool) { + // 函数执行后返回值是 Promise + if (isPromise(bool)) { + return ; + } return target; } - // 函数执行后返回值是 Promise - if (isPromise(bool)) { - return ; - } return Exception; } catch (error) { throw error; From e685dc6881cfb72a0c1d7a5657e0989d6659dd0f Mon Sep 17 00:00:00 2001 From: guowenfh Date: Thu, 14 Jun 2018 00:40:37 +0800 Subject: [PATCH 17/31] fix chechPermissions.js isPromise(bool) --- src/components/Authorized/CheckPermissions.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Authorized/CheckPermissions.js b/src/components/Authorized/CheckPermissions.js index 0c3b9a4c..06dc0ab9 100644 --- a/src/components/Authorized/CheckPermissions.js +++ b/src/components/Authorized/CheckPermissions.js @@ -49,11 +49,11 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => { if (typeof authority === 'function') { try { const bool = authority(currentAuthority); + // 函数执行后返回值是 Promise + if (isPromise(bool)) { + return ; + } if (bool) { - // 函数执行后返回值是 Promise - if (isPromise(bool)) { - return ; - } return target; } return Exception; From 631b6658a86c93463b251a05ad0f3465d2ce2a53 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 19 Jun 2018 14:55:56 +0800 Subject: [PATCH 18/31] Fix PageHeader align --- src/components/PageHeader/index.less | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/PageHeader/index.less b/src/components/PageHeader/index.less index 13324b97..76d38f10 100644 --- a/src/components/PageHeader/index.less +++ b/src/components/PageHeader/index.less @@ -69,6 +69,9 @@ .main { flex: 0 1 auto; } + .content { + flex: auto; + } .main { width: 100%; } From 2465ac2c3085193d9101115f2c0bcb19d7d74515 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 20 Jun 2018 12:03:20 +0800 Subject: [PATCH 19/31] Fix PageHeader align issue, close #1693 --- src/components/PageHeader/index.less | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/PageHeader/index.less b/src/components/PageHeader/index.less index 76d38f10..efc581ab 100644 --- a/src/components/PageHeader/index.less +++ b/src/components/PageHeader/index.less @@ -63,18 +63,20 @@ } .title, + .content { + flex: auto; + } + .action, - .content, .extraContent, .main { flex: 0 1 auto; } - .content { - flex: auto; - } + .main { width: 100%; } + .title, .action { margin-bottom: 16px; From 43a570da7c5b98d63a5b9e55d18a88ed21c6f680 Mon Sep 17 00:00:00 2001 From: Amumu Date: Wed, 20 Jun 2018 19:57:29 +0800 Subject: [PATCH 20/31] For robustness close #1661 --- src/components/GlobalHeader/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/GlobalHeader/index.js b/src/components/GlobalHeader/index.js index 10aea499..0f405f7b 100644 --- a/src/components/GlobalHeader/index.js +++ b/src/components/GlobalHeader/index.js @@ -13,8 +13,8 @@ export default class GlobalHeader extends PureComponent { this.triggerResizeEvent.cancel(); } getNoticeData() { - const { notices = [] } = this.props; - if (notices.length === 0) { + const { notices} = this.props; + if (notices == null || notices.length === 0) { return {}; } const newNotices = notices.map(notice => { @@ -66,6 +66,9 @@ export default class GlobalHeader extends PureComponent { onMenuClick, onNoticeClear, } = this.props; + if (currentUser == null) { + currentUser = {} + } const menu = ( From 72e765b20548eef9ff18e7eec1025b464632852c Mon Sep 17 00:00:00 2001 From: Amumu Date: Wed, 20 Jun 2018 20:49:17 +0800 Subject: [PATCH 21/31] fix global hmr error --- src/layouts/BasicLayout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index b0ae923c..e587bc95 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -281,7 +281,7 @@ class BasicLayout extends React.PureComponent { } } -export default connect(({ user, global, loading }) => ({ +export default connect(({ user, global = {}, loading }) => ({ currentUser: user.currentUser, collapsed: global.collapsed, fetchingNotices: loading.effects['global/fetchNotices'], From 9b08f2ea3ee954bc9afb4fc863de6ee41da65c93 Mon Sep 17 00:00:00 2001 From: zhiyan Date: Thu, 21 Jun 2018 11:29:14 +0800 Subject: [PATCH 22/31] fix: isUrl func failed && support judge url with port --- src/utils/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index 9700b31e..5385e42f 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -162,7 +162,7 @@ export function getRoutes(path, routerData) { } /* eslint no-useless-escape:0 */ -const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/g; +const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; export function isUrl(path) { return reg.test(path); From 70448f06b6c7234fc87aae5c750520ead8acaf8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Fri, 22 Jun 2018 18:58:20 +0800 Subject: [PATCH 23/31] externals bizcharts dataset and rollbar --- .webpackrc.js | 9 ++++++--- src/index.ejs | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.webpackrc.js b/.webpackrc.js index ce65d311..e0bedf69 100755 --- a/.webpackrc.js +++ b/.webpackrc.js @@ -2,14 +2,17 @@ const path = require('path'); export default { entry: 'src/index.js', - extraBabelPlugins: [ - ['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }], - ], + extraBabelPlugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]], env: { development: { extraBabelPlugins: ['dva-hmr'], }, }, + externals: { + '@antv/data-set': 'DataSet', + bizcharts: 'BizCharts', + rollbar: 'rollbar', + }, alias: { components: path.resolve(__dirname, 'src/components/'), }, diff --git a/src/index.ejs b/src/index.ejs index 586f62e8..777b30ee 100644 --- a/src/index.ejs +++ b/src/index.ejs @@ -7,6 +7,10 @@ Ant Design Pro + + + From fc8c9a5159bf6b3413747fb38bd672d2d2310670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Fri, 22 Jun 2018 19:01:26 +0800 Subject: [PATCH 24/31] upgrade modules --- .webpackrc.js | 3 +++ package.json | 13 ++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.webpackrc.js b/.webpackrc.js index e0bedf69..8515c0b4 100755 --- a/.webpackrc.js +++ b/.webpackrc.js @@ -21,6 +21,9 @@ export default { html: { template: './src/index.ejs', }, + lessLoaderOptions: { + javascriptEnabled: true, + }, disableDynamicImport: true, publicPath: '/', hash: true, diff --git a/package.json b/package.json index 4c810773..45993882 100755 --- a/package.json +++ b/package.json @@ -26,15 +26,14 @@ "antd": "^3.4.3", "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-runtime": "^6.9.2", - "bizcharts": "^3.1.5", + "bizcharts": "^3.1.10", "bizcharts-plugin-slider": "^2.0.1", "classnames": "^2.2.5", "dva": "^2.2.3", "dva-loading": "^2.0.3", "enquire-js": "^0.2.1", - "less": "2.7.2", "lodash": "^4.17.10", - "lodash-decorators": "^5.0.0", + "lodash-decorators": "^6.0.0", "moment": "^2.19.1", "numeral": "^2.0.6", "omit.js": "^1.0.0", @@ -42,10 +41,10 @@ "prop-types": "^15.5.10", "qs": "^6.5.0", "rc-drawer": "^1.2.0", - "react": "^16.2.0", + "react": "^16.4.1", "react-container-query": "^0.11.0", "react-document-title": "^2.0.3", - "react-dom": "^16.2.0", + "react-dom": "^16.4.1", "react-fittext": "^1.0.0", "rollbar": "^2.3.4", "url-polyfill": "^1.0.10" @@ -59,7 +58,7 @@ "cross-port-killer": "^1.0.1", "enzyme": "^3.1.0", "eslint": "^4.14.0", - "eslint-config-airbnb": "^16.0.0", + "eslint-config-airbnb": "^17.0.0", "eslint-config-prettier": "^2.9.0", "eslint-plugin-babel": "^5.1.0", "eslint-plugin-compat": "^2.1.0", @@ -75,7 +74,7 @@ "pro-download": "^1.0.1", "redbox-react": "^1.5.0", "regenerator-runtime": "^0.11.1", - "roadhog": "^2.4.1", + "roadhog": "^1.4.1", "roadhog-api-doc": "^1.0.3", "stylelint": "^9.2.1", "stylelint-config-prettier": "^3.0.4", From 84a05cbd18d0bda34aaff69a8c88e80c0fbd577a Mon Sep 17 00:00:00 2001 From: Kevin Lee Date: Fri, 22 Jun 2018 17:01:14 +0800 Subject: [PATCH 25/31] =?UTF-8?q?fix:=20HeaderSearch=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=E5=AF=B9=20enter=20=E9=94=AE?= =?UTF-8?q?=E7=9A=84=E9=98=B2=E6=8A=96=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 删除无用 timeout 代码 2. 利用 lodash 中的 debounce 函数增加防抖处理 3. 添加 gitignore 规则,排除 VSC 插件生成的 .history 文件夹 close #1703 --- .gitignore | 3 +++ src/components/HeaderSearch/index.js | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 59a03667..1da27e1b 100755 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ yarn.lock package-lock.json *bak jsconfig.json + +# visual studio code +.history \ No newline at end of file diff --git a/src/components/HeaderSearch/index.js b/src/components/HeaderSearch/index.js index 855e7ac1..a08ad7f4 100644 --- a/src/components/HeaderSearch/index.js +++ b/src/components/HeaderSearch/index.js @@ -2,6 +2,8 @@ import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { Input, Icon, AutoComplete } from 'antd'; import classNames from 'classnames'; +import Debounce from 'lodash-decorators/debounce'; +import Bind from 'lodash-decorators/bind'; import styles from './index.less'; export default class HeaderSearch extends PureComponent { @@ -29,14 +31,9 @@ export default class HeaderSearch extends PureComponent { searchMode: this.props.defaultOpen, value: '', }; - componentWillUnmount() { - clearTimeout(this.timeout); - } onKeyDown = e => { if (e.key === 'Enter') { - this.timeout = setTimeout(() => { - this.props.onPressEnter(this.state.value); // Fix duplicate onPressEnter - }, 0); + this.debouncePressEnter(); } }; onChange = value => { @@ -45,6 +42,15 @@ export default class HeaderSearch extends PureComponent { this.props.onChange(); } }; + // NOTE: 不能小于500,如果长按某键,第一次触发auto repeat的间隔是500ms,小于500会导致触发2次 + @Bind() + @Debounce(500, { + leading: true, + trailing: false, + }) + debouncePressEnter() { + this.props.onPressEnter(this.state.value); + } enterSearchMode = () => { this.setState({ searchMode: true }, () => { if (this.state.searchMode) { From 9a4ddb962502141d95a30c863c0d0c3078883d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Fri, 22 Jun 2018 19:38:30 +0800 Subject: [PATCH 26/31] Recover roadhog version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 45993882..7c8395da 100755 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "pro-download": "^1.0.1", "redbox-react": "^1.5.0", "regenerator-runtime": "^0.11.1", - "roadhog": "^1.4.1", + "roadhog": "^2.4.2", "roadhog-api-doc": "^1.0.3", "stylelint": "^9.2.1", "stylelint-config-prettier": "^3.0.4", From 484d71d8e179790f78e9c739c54102639beb7505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Sat, 23 Jun 2018 07:51:21 +0800 Subject: [PATCH 27/31] vscode support alias --- .gitignore | 1 - jsconfig.json | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 jsconfig.json diff --git a/.gitignore b/.gitignore index 1da27e1b..c8978582 100755 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,6 @@ yarn-error.log yarn.lock package-lock.json *bak -jsconfig.json # visual studio code .history \ No newline at end of file diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 00000000..5475bee0 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "baseUrl": ".", + "paths": { + "components/*": ["./src/components/*"] + } + } +} From d7b87c27dbb0f1a70352e0c702516128f8907d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Sun, 24 Jun 2018 09:42:24 +0800 Subject: [PATCH 28/31] fix some eslint error --- .eslintrc.js | 1 + src/components/Authorized/PromiseRender.js | 5 +++ src/components/Charts/TimelineChart/index.js | 3 +- src/components/Charts/WaterWave/index.js | 5 ++- src/components/CountDown/index.js | 10 ++++- src/components/DescriptionList/Description.js | 4 +- .../DescriptionList/DescriptionList.js | 5 ++- src/components/EditableItem/index.js | 4 ++ src/components/EditableLinkGroup/index.js | 1 + src/components/GlobalHeader/index.js | 6 ++- src/components/HeaderSearch/index.js | 6 +++ src/components/Login/LoginItem.js | 5 +++ src/components/Login/LoginTab.js | 4 ++ src/components/Login/index.js | 4 ++ src/components/NoticeIcon/index.js | 5 +++ src/components/PageHeader/index.js | 7 +++ src/components/SiderMenu/SiderMenu.js | 45 ++++++++++++------- src/components/StandardTable/index.js | 10 ++++- src/components/TagSelect/index.js | 1 + src/layouts/BasicLayout.js | 11 +++++ src/layouts/UserLayout.js | 1 + src/routes/Dashboard/Analysis.js | 29 +++++++----- src/routes/Dashboard/Workplace.js | 7 ++- src/routes/Exception/triggerException.js | 2 + src/routes/Forms/AdvancedForm.js | 4 ++ src/routes/Forms/BasicForm.js | 7 ++- src/routes/Forms/StepForm/Step2.js | 6 ++- src/routes/Forms/StepForm/index.js | 1 + src/routes/Forms/TableForm.js | 12 +++++ src/routes/List/Applications.js | 6 ++- src/routes/List/Articles.js | 9 +++- src/routes/List/BasicList.js | 5 ++- src/routes/List/CardList.js | 5 ++- src/routes/List/Projects.js | 6 ++- src/routes/List/TableList.js | 5 ++- src/routes/Profile/AdvancedProfile.js | 3 +- src/routes/Result/Error.js | 6 ++- src/routes/Result/Success.js | 6 ++- src/routes/User/RegisterResult.js | 3 +- 39 files changed, 211 insertions(+), 54 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index e29c1a8a..c20a185d 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/Authorized/PromiseRender.js b/src/components/Authorized/PromiseRender.js index 02518ad5..b18bcbec 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); } + componentWillReceiveProps(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,6 +42,7 @@ export default class PromiseRender extends React.PureComponent { } return () => target; }; + render() { const Component = this.state.component; return Component ? ( diff --git a/src/components/Charts/TimelineChart/index.js b/src/components/Charts/TimelineChart/index.js index e7ab6b11..018464da 100644 --- a/src/components/Charts/TimelineChart/index.js +++ b/src/components/Charts/TimelineChart/index.js @@ -44,8 +44,7 @@ export default class TimelineChart extends React.Component { }); const dv = ds.createView(); - dv - .source(data) + dv.source(data) .transform({ type: 'filter', callback: obj => { diff --git a/src/components/Charts/WaterWave/index.js b/src/components/Charts/WaterWave/index.js index 70938427..5ea6dcc3 100644 --- a/src/components/Charts/WaterWave/index.js +++ b/src/components/Charts/WaterWave/index.js @@ -189,7 +189,10 @@ export default class WaterWave extends PureComponent {
{title && {title}} -

{percent}%

+

+ {percent} + % +

); diff --git a/src/components/CountDown/index.js b/src/components/CountDown/index.js index 875fb1e2..b67fab2f 100644 --- a/src/components/CountDown/index.js +++ b/src/components/CountDown/index.js @@ -39,7 +39,9 @@ class CountDown extends Component { } timer = 0; + interval = 1000; + initTime = props => { let lastTime = 0; let targetTime = 0; @@ -58,6 +60,7 @@ class CountDown extends Component { lastTime: lastTime < 0 ? 0 : lastTime, }; }; + // defaultFormat = time => ( // {moment(time).format('hh:mm:ss')} // ); @@ -70,10 +73,15 @@ class CountDown extends Component { const s = Math.floor((time - h * hours - m * minutes) / 1000); return ( - {fixedZero(h)}:{fixedZero(m)}:{fixedZero(s)} + {fixedZero(h)} + : + {fixedZero(m)} + : + {fixedZero(s)} ); }; + tick = () => { const { onEnd } = this.props; let { lastTime } = this.state; diff --git a/src/components/DescriptionList/Description.js b/src/components/DescriptionList/Description.js index 3e41c071..002ad284 100644 --- a/src/components/DescriptionList/Description.js +++ b/src/components/DescriptionList/Description.js @@ -10,8 +10,8 @@ const Description = ({ term, column, className, children, ...restProps }) => { return ( {term &&
{term}
} - {children !== null && children !== undefined && -
{children}
} + {children !== null && + children !== undefined &&
{children}
} ); }; diff --git a/src/components/DescriptionList/DescriptionList.js b/src/components/DescriptionList/DescriptionList.js index 382d7e85..73bb5f5f 100644 --- a/src/components/DescriptionList/DescriptionList.js +++ b/src/components/DescriptionList/DescriptionList.js @@ -22,7 +22,10 @@ const DescriptionList = ({
{title ?
{title}
: null} - {React.Children.map(children, child => child ? React.cloneElement(child, { column }) : child)} + {React.Children.map( + children, + child => (child ? React.cloneElement(child, { column }) : child) + )}
); diff --git a/src/components/EditableItem/index.js b/src/components/EditableItem/index.js index fcda844e..5b22631c 100644 --- a/src/components/EditableItem/index.js +++ b/src/components/EditableItem/index.js @@ -7,19 +7,23 @@ export default class EditableItem extends PureComponent { value: this.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); } }; + 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 2d0b4aa8..ae3d93c7 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/index.js b/src/components/GlobalHeader/index.js index 0f405f7b..f84d2d2e 100644 --- a/src/components/GlobalHeader/index.js +++ b/src/components/GlobalHeader/index.js @@ -12,8 +12,9 @@ export default class GlobalHeader extends PureComponent { componentWillUnmount() { this.triggerResizeEvent.cancel(); } + getNoticeData() { - const { notices} = this.props; + const { notices } = this.props; if (notices == null || notices.length === 0) { return {}; } @@ -43,6 +44,7 @@ export default class GlobalHeader extends PureComponent { }); return groupBy(newNotices, 'type'); } + toggle = () => { const { collapsed, onCollapse } = this.props; onCollapse(!collapsed); @@ -67,7 +69,7 @@ export default class GlobalHeader extends PureComponent { onNoticeClear, } = this.props; if (currentUser == null) { - currentUser = {} + currentUser = {}; } const menu = ( diff --git a/src/components/HeaderSearch/index.js b/src/components/HeaderSearch/index.js index a08ad7f4..de8a6be5 100644 --- a/src/components/HeaderSearch/index.js +++ b/src/components/HeaderSearch/index.js @@ -31,17 +31,20 @@ export default class HeaderSearch extends PureComponent { searchMode: this.props.defaultOpen, value: '', }; + onKeyDown = e => { if (e.key === 'Enter') { this.debouncePressEnter(); } }; + onChange = value => { this.setState({ value }); if (this.props.onChange) { this.props.onChange(); } }; + // NOTE: 不能小于500,如果长按某键,第一次触发auto repeat的间隔是500ms,小于500会导致触发2次 @Bind() @Debounce(500, { @@ -51,6 +54,7 @@ export default class HeaderSearch extends PureComponent { debouncePressEnter() { this.props.onPressEnter(this.state.value); } + enterSearchMode = () => { this.setState({ searchMode: true }, () => { if (this.state.searchMode) { @@ -58,12 +62,14 @@ export default class HeaderSearch extends PureComponent { } }); }; + leaveSearchMode = () => { this.setState({ searchMode: false, value: '', }); }; + render() { const { className, placeholder, ...restProps } = this.props; delete restProps.defaultOpen; // for rc-select not affected diff --git a/src/components/Login/LoginItem.js b/src/components/Login/LoginItem.js index 98efb333..a4504ad5 100644 --- a/src/components/Login/LoginItem.js +++ b/src/components/Login/LoginItem.js @@ -14,20 +14,24 @@ function generator({ defaultProps, defaultRules, type }) { form: PropTypes.object, updateActive: PropTypes.func, }; + constructor(props) { super(props); this.state = { count: 0, }; } + componentDidMount() { if (this.context.updateActive) { this.context.updateActive(this.props.name); } } + componentWillUnmount() { clearInterval(this.interval); } + onGetCaptcha = () => { let count = 59; this.setState({ count }); @@ -42,6 +46,7 @@ function generator({ defaultProps, defaultRules, type }) { } }, 1000); }; + render() { const { getFieldDecorator } = this.context.form; const options = {}; diff --git a/src/components/Login/LoginTab.js b/src/components/Login/LoginTab.js index 750bfe7c..52de12d2 100644 --- a/src/components/Login/LoginTab.js +++ b/src/components/Login/LoginTab.js @@ -14,18 +14,22 @@ const generateId = (() => { export default class LoginTab extends Component { static __ANT_PRO_LOGIN_TAB = true; + static contextTypes = { tabUtil: PropTypes.object, }; + constructor(props) { super(props); this.uniqueId = generateId('login-tab-'); } + componentWillMount() { if (this.context.tabUtil) { this.context.tabUtil.addTab(this.uniqueId); } } + render() { return ; } diff --git a/src/components/Login/index.js b/src/components/Login/index.js index 58c4e468..31235017 100644 --- a/src/components/Login/index.js +++ b/src/components/Login/index.js @@ -33,6 +33,7 @@ class Login extends Component { tabs: [], active: {}, }; + getChildContext() { return { tabUtil: { @@ -61,12 +62,14 @@ class Login extends Component { }, }; } + onSwitch = type => { this.setState({ type, }); this.props.onTabChange(type); }; + handleSubmit = e => { e.preventDefault(); const { active, type } = this.state; @@ -75,6 +78,7 @@ class Login extends Component { this.props.onSubmit(err, values); }); }; + render() { const { className, children } = this.props; const { type, tabs } = this.state; diff --git a/src/components/NoticeIcon/index.js b/src/components/NoticeIcon/index.js index a207be86..5561f0ef 100644 --- a/src/components/NoticeIcon/index.js +++ b/src/components/NoticeIcon/index.js @@ -21,6 +21,7 @@ export default class NoticeIcon extends PureComponent { }, emptyImage: 'https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg', }; + constructor(props) { super(props); this.state = {}; @@ -28,14 +29,17 @@ export default class NoticeIcon extends PureComponent { this.state.tabType = props.children[0].props.title; } } + onItemClick = (item, tabProps) => { const { onItemClick } = this.props; onItemClick(item, tabProps); }; + onTabChange = tabType => { this.setState({ tabType }); this.props.onTabChange(tabType); }; + getNotificationBox() { const { children, loading, locale } = this.props; if (!children) { @@ -67,6 +71,7 @@ export default class NoticeIcon extends PureComponent { ); } + render() { const { className, count, popupAlign, onPopupVisibleChange } = this.props; const noticeButtonClass = classNames(className, styles.noticeButton); diff --git a/src/components/PageHeader/index.js b/src/components/PageHeader/index.js index 3080ed04..ac9f628c 100644 --- a/src/components/PageHeader/index.js +++ b/src/components/PageHeader/index.js @@ -40,11 +40,13 @@ export default class PageHeader extends PureComponent { this.getBreadcrumbDom(); } } + onChange = key => { if (this.props.onTabChange) { this.props.onTabChange(key); } }; + getBreadcrumbProps = () => { return { routes: this.props.routes || this.context.routes, @@ -53,12 +55,14 @@ export default class PageHeader extends PureComponent { breadcrumbNameMap: this.props.breadcrumbNameMap || this.context.breadcrumbNameMap, }; }; + getBreadcrumbDom = () => { const breadcrumb = this.conversionBreadcrumbList(); this.setState({ breadcrumb, }); }; + // Generated according to props conversionFromProps = () => { const { breadcrumbList, breadcrumbSeparator, linkElement = 'a' } = this.props; @@ -80,6 +84,7 @@ export default class PageHeader extends PureComponent { ); }; + conversionFromLocation = (routerLocation, breadcrumbNameMap) => { const { breadcrumbSeparator, linkElement = 'a' } = this.props; // Convert the url to an array @@ -116,6 +121,7 @@ export default class PageHeader extends PureComponent { ); }; + /** * 将参数转化为面包屑 * Convert parameters into breadcrumbs @@ -146,6 +152,7 @@ export default class PageHeader extends PureComponent { } return null; }; + // 渲染Breadcrumb 子节点 // Render the Breadcrumb child node itemRender = (route, params, routes, paths) => { diff --git a/src/components/SiderMenu/SiderMenu.js b/src/components/SiderMenu/SiderMenu.js index 2068b7b8..fc93fca8 100644 --- a/src/components/SiderMenu/SiderMenu.js +++ b/src/components/SiderMenu/SiderMenu.js @@ -28,14 +28,13 @@ const getIcon = icon => { * @param menu */ export const getFlatMenuKeys = menu => - menu - .reduce((keys, item) => { - keys.push(item.path); - if (item.children) { - return keys.concat(getFlatMenuKeys(item.children)); - } - return keys; - }, []); + menu.reduce((keys, item) => { + keys.push(item.path); + if (item.children) { + return keys.concat(getFlatMenuKeys(item.children)); + } + return keys; + }, []); /** * Find all matched menu keys based on paths @@ -43,11 +42,11 @@ export const getFlatMenuKeys = menu => * @param paths: [/abc, /abc/11, /abc/11/info] */ export const getMenuMatchKeys = (flatMenuKeys, paths) => - paths - .reduce((matchKeys, path) => ( - matchKeys.concat( - flatMenuKeys.filter(item => pathToRegexp(item).test(path)) - )), []); + paths.reduce( + (matchKeys, path) => + matchKeys.concat(flatMenuKeys.filter(item => pathToRegexp(item).test(path))), + [] + ); export default class SiderMenu extends PureComponent { constructor(props) { @@ -58,6 +57,7 @@ export default class SiderMenu extends PureComponent { openKeys: this.getDefaultCollapsedSubMenus(props), }; } + componentWillReceiveProps(nextProps) { if (nextProps.location.pathname !== this.props.location.pathname) { this.setState({ @@ -65,15 +65,20 @@ export default class SiderMenu extends PureComponent { }); } } + /** * Convert pathname to openKeys * /list/search/articles = > ['list','/list/search'] * @param props */ getDefaultCollapsedSubMenus(props) { - const { location: { pathname } } = props || this.props; + const { + location: { pathname }, + } = + props || this.props; return getMenuMatchKeys(this.flatMenuKeys, urlToList(pathname)); } + /** * 判断是否是http链接.返回 Link 或 a * Judge whether it is http link.return a or Link @@ -110,6 +115,7 @@ export default class SiderMenu extends PureComponent { ); }; + /** * get SubMenu or Item */ @@ -141,6 +147,7 @@ export default class SiderMenu extends PureComponent { return {this.getMenuItemPath(item)}; } }; + /** * 获得菜单子节点 * @memberof SiderMenu @@ -158,11 +165,15 @@ export default class SiderMenu extends PureComponent { }) .filter(item => item); }; + // Get the currently selected menu getSelectedMenuKeys = () => { - const { location: { pathname } } = this.props; + const { + location: { pathname }, + } = this.props; return getMenuMatchKeys(this.flatMenuKeys, urlToList(pathname)); }; + // conversion Path // 转化路径 conversionPath = path => { @@ -172,6 +183,7 @@ export default class SiderMenu extends PureComponent { return `/${path || ''}`.replace(/\/+/g, '/'); } }; + // permission to check checkPermissionItem = (authority, ItemDom) => { if (this.props.Authorized && this.props.Authorized.check) { @@ -180,9 +192,11 @@ export default class SiderMenu extends PureComponent { } return ItemDom; }; + isMainMenu = key => { return this.menus.some(item => key && (item.key === key || item.path === key)); }; + handleOpenChange = openKeys => { const lastOpenKey = openKeys[openKeys.length - 1]; const moreThanOne = openKeys.filter(openKey => this.isMainMenu(openKey)).length > 1; @@ -190,6 +204,7 @@ export default class SiderMenu extends PureComponent { openKeys: moreThanOne ? [lastOpenKey] : [...openKeys], }); }; + render() { const { logo, collapsed, onCollapse } = this.props; const { openKeys } = this.state; diff --git a/src/components/StandardTable/index.js b/src/components/StandardTable/index.js index 281d60e6..ea255cf8 100644 --- a/src/components/StandardTable/index.js +++ b/src/components/StandardTable/index.js @@ -63,7 +63,12 @@ class StandardTable extends PureComponent { render() { const { selectedRowKeys, needTotalList } = this.state; - const { data: { list, pagination }, loading, columns, rowKey } = this.props; + const { + data: { list, pagination }, + loading, + columns, + rowKey, + } = this.props; const paginationProps = { showSizeChanger: true, @@ -88,7 +93,8 @@ class StandardTable extends PureComponent { 已选择 {selectedRowKeys.length} 项   {needTotalList.map(item => ( - {item.title}总计  + {item.title} + 总计  {item.render ? item.render(item.total) : item.total} diff --git a/src/components/TagSelect/index.js b/src/components/TagSelect/index.js index 773b9c84..d86425c1 100644 --- a/src/components/TagSelect/index.js +++ b/src/components/TagSelect/index.js @@ -19,6 +19,7 @@ class TagSelect extends Component { expand: false, value: this.props.value || this.props.defaultValue || [], }; + componentWillReceiveProps(nextProps) { if ('value' in nextProps && nextProps.value) { this.setState({ value: nextProps.value }); diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index e587bc95..a6350edf 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -89,9 +89,11 @@ class BasicLayout extends React.PureComponent { location: PropTypes.object, breadcrumbNameMap: PropTypes.object, }; + state = { isMobile, }; + getChildContext() { const { location, routerData } = this.props; return { @@ -99,6 +101,7 @@ class BasicLayout extends React.PureComponent { breadcrumbNameMap: getBreadcrumbNameMap(getMenuData(), routerData), }; } + componentDidMount() { this.enquireHandler = enquireScreen(mobile => { this.setState({ @@ -109,9 +112,11 @@ class BasicLayout extends React.PureComponent { type: 'user/fetchCurrent', }); } + componentWillUnmount() { unenquireScreen(this.enquireHandler); } + getPageTitle() { const { routerData, location } = this.props; const { pathname } = location; @@ -128,6 +133,7 @@ class BasicLayout extends React.PureComponent { } return title; } + getBaseRedirect = () => { // According to the url parameter to redirect // 这里是重定向的,重定向到 url 的 redirect 参数所示地址 @@ -148,12 +154,14 @@ class BasicLayout extends React.PureComponent { } return redirect; }; + handleMenuCollapse = collapsed => { this.props.dispatch({ type: 'global/changeLayoutCollapsed', payload: collapsed, }); }; + handleNoticeClear = type => { message.success(`清空了${type}`); this.props.dispatch({ @@ -161,6 +169,7 @@ class BasicLayout extends React.PureComponent { payload: type, }); }; + handleMenuClick = ({ key }) => { if (key === 'triggerError') { this.props.dispatch(routerRedux.push('/exception/trigger')); @@ -172,6 +181,7 @@ class BasicLayout extends React.PureComponent { }); } }; + handleNoticeVisibleChange = visible => { if (visible) { this.props.dispatch({ @@ -179,6 +189,7 @@ class BasicLayout extends React.PureComponent { }); } }; + render() { const { currentUser, diff --git a/src/layouts/UserLayout.js b/src/layouts/UserLayout.js index 8fb53534..447f44fb 100644 --- a/src/layouts/UserLayout.js +++ b/src/layouts/UserLayout.js @@ -41,6 +41,7 @@ class UserLayout extends React.PureComponent { } return title; } + render() { const { routerData, match } = this.props; return ( diff --git a/src/routes/Dashboard/Analysis.js b/src/routes/Dashboard/Analysis.js index 5e691e42..61704899 100644 --- a/src/routes/Dashboard/Analysis.js +++ b/src/routes/Dashboard/Analysis.js @@ -43,7 +43,9 @@ for (let i = 0; i < 7; i += 1) { } const Yuan = ({ children }) => ( - /* eslint-disable-line react/no-danger */ + /* eslint-disable-line react/no-danger */ ); @connect(({ chart, loading }) => ({ @@ -134,7 +136,9 @@ export default class Analysis extends Component { const salesPieData = salesType === 'all' ? salesTypeData - : salesType === 'online' ? salesTypeDataOnline : salesTypeDataOffline; + : salesType === 'online' + ? salesTypeDataOnline + : salesTypeDataOffline; const menu = ( @@ -201,7 +205,10 @@ export default class Analysis extends Component { sorter: (a, b) => a.range - b.range, render: (text, record) => ( - {text}% + + {text} + % + ), align: 'right', @@ -261,10 +268,12 @@ export default class Analysis extends Component { contentHeight={46} > - 周同比12% + 周同比 + 12% - 日环比11% + 日环比 + 11% @@ -313,10 +322,12 @@ export default class Analysis extends Component { footer={
- 周同比12% + 周同比 + 12% - 日环比11% + 日环比 + 11%
} @@ -455,9 +466,7 @@ export default class Analysis extends Component { {salesPieData.reduce((pre, now) => now.y + pre, 0)} - } + total={() => {salesPieData.reduce((pre, now) => now.y + pre, 0)}} data={salesPieData} valueFormat={value => {value}} height={248} diff --git a/src/routes/Dashboard/Workplace.js b/src/routes/Dashboard/Workplace.js index 9c8bdc79..44885618 100644 --- a/src/routes/Dashboard/Workplace.js +++ b/src/routes/Dashboard/Workplace.js @@ -99,7 +99,9 @@ export default class Workplace extends PureComponent { } renderActivities() { - const { activities: { list } } = this.props; + const { + activities: { list }, + } = this.props; return list.map(item => { const events = item.template.split(/@\{([^{}]*)\}/gi).map(key => { if (item[key]) { @@ -165,7 +167,8 @@ export default class Workplace extends PureComponent {

团队内排名

- 8 / 24 + 8 + / 24

diff --git a/src/routes/Exception/triggerException.js b/src/routes/Exception/triggerException.js index 2dccfb75..4699d458 100644 --- a/src/routes/Exception/triggerException.js +++ b/src/routes/Exception/triggerException.js @@ -10,6 +10,7 @@ export default class TriggerException extends PureComponent { state = { isloading: false, }; + triggerError = code => { this.setState({ isloading: true, @@ -21,6 +22,7 @@ export default class TriggerException extends PureComponent { }, }); }; + render() { return ( diff --git a/src/routes/Forms/AdvancedForm.js b/src/routes/Forms/AdvancedForm.js index 16b7e3b0..741a37b1 100644 --- a/src/routes/Forms/AdvancedForm.js +++ b/src/routes/Forms/AdvancedForm.js @@ -61,12 +61,15 @@ class AdvancedForm extends PureComponent { state = { width: '100%', }; + componentDidMount() { window.addEventListener('resize', this.resizeFooterToolbar); } + componentWillUnmount() { window.removeEventListener('resize', this.resizeFooterToolbar); } + resizeFooterToolbar = () => { const sider = document.querySelectorAll('.ant-layout-sider')[0]; const width = `calc(100% - ${sider.style.width})`; @@ -74,6 +77,7 @@ class AdvancedForm extends PureComponent { this.setState({ width }); } }; + render() { const { form, dispatch, submitting } = this.props; const { getFieldDecorator, validateFieldsAndScroll, getFieldsError } = form; diff --git a/src/routes/Forms/BasicForm.js b/src/routes/Forms/BasicForm.js index ed41cb3b..7f5c7e0b 100644 --- a/src/routes/Forms/BasicForm.js +++ b/src/routes/Forms/BasicForm.js @@ -36,6 +36,7 @@ export default class BasicForms extends PureComponent { } }); }; + render() { const { submitting } = this.props; const { getFieldDecorator, getFieldValue } = this.props.form; @@ -134,7 +135,8 @@ export default class BasicForms extends PureComponent { {...formItemLayout} label={ - 邀评人(选填) + 邀评人 + (选填) } > @@ -146,7 +148,8 @@ export default class BasicForms extends PureComponent { {...formItemLayout} label={ - 权重(选填) + 权重 + (选填) } > diff --git a/src/routes/Forms/StepForm/Step2.js b/src/routes/Forms/StepForm/Step2.js index 4e7df540..9b142007 100644 --- a/src/routes/Forms/StepForm/Step2.js +++ b/src/routes/Forms/StepForm/Step2.js @@ -55,7 +55,11 @@ class Step2 extends React.PureComponent { {data.amount} - ({digitUppercase(data.amount)}) + + ( + {digitUppercase(data.amount)} + ) + diff --git a/src/routes/Forms/StepForm/index.js b/src/routes/Forms/StepForm/index.js index 3ab2374b..5b7f703c 100644 --- a/src/routes/Forms/StepForm/index.js +++ b/src/routes/Forms/StepForm/index.js @@ -24,6 +24,7 @@ export default class StepForm extends PureComponent { return 0; } } + render() { const { match, routerData, location } = this.props; return ( diff --git a/src/routes/Forms/TableForm.js b/src/routes/Forms/TableForm.js index 0cc07fd1..65b679d5 100644 --- a/src/routes/Forms/TableForm.js +++ b/src/routes/Forms/TableForm.js @@ -11,6 +11,7 @@ export default class TableForm extends PureComponent { loading: false, }; } + componentWillReceiveProps(nextProps) { if ('value' in nextProps) { this.setState({ @@ -18,11 +19,15 @@ export default class TableForm extends PureComponent { }); } } + getRowByKey(key, newData) { return (newData || this.state.data).filter(item => item.key === key)[0]; } + index = 0; + cacheOriginData = {}; + toggleEditable = (e, key) => { e.preventDefault(); const newData = this.state.data.map(item => ({ ...item })); @@ -36,11 +41,13 @@ export default class TableForm extends PureComponent { this.setState({ data: newData }); } }; + remove(key) { const newData = this.state.data.filter(item => item.key !== key); this.setState({ data: newData }); this.props.onChange(newData); } + newMember = () => { const newData = this.state.data.map(item => ({ ...item })); newData.push({ @@ -54,11 +61,13 @@ export default class TableForm extends PureComponent { this.index += 1; this.setState({ data: newData }); }; + handleKeyPress(e, key) { if (e.key === 'Enter') { this.saveRow(e, key); } } + handleFieldChange(e, fieldName, key) { const newData = this.state.data.map(item => ({ ...item })); const target = this.getRowByKey(key, newData); @@ -67,6 +76,7 @@ export default class TableForm extends PureComponent { this.setState({ data: newData }); } } + saveRow(e, key) { e.persist(); this.setState({ @@ -94,6 +104,7 @@ export default class TableForm extends PureComponent { }); }, 500); } + cancel(e, key) { this.clickedCancel = true; e.preventDefault(); @@ -107,6 +118,7 @@ export default class TableForm extends PureComponent { this.setState({ data: newData }); this.clickedCancel = false; } + render() { const columns = [ { diff --git a/src/routes/List/Applications.js b/src/routes/List/Applications.js index bfc33375..60a846f5 100644 --- a/src/routes/List/Applications.js +++ b/src/routes/List/Applications.js @@ -63,7 +63,11 @@ 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 2f6b639d..405f8ec5 100644 --- a/src/routes/List/Articles.js +++ b/src/routes/List/Articles.js @@ -39,7 +39,11 @@ 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 = [ @@ -77,7 +81,8 @@ export default class SearchList extends Component {
{content}
- {owner} 发布在 {href} + {owner} 发布在 + {href} {moment(updatedAt).format('YYYY-MM-DD HH:mm')}
diff --git a/src/routes/List/BasicList.js b/src/routes/List/BasicList.js index 78e81192..155be87c 100644 --- a/src/routes/List/BasicList.js +++ b/src/routes/List/BasicList.js @@ -39,7 +39,10 @@ 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 8111770f..1441596e 100644 --- a/src/routes/List/CardList.js +++ b/src/routes/List/CardList.js @@ -22,7 +22,10 @@ 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 1617cf55..b1720972 100644 --- a/src/routes/List/Projects.js +++ b/src/routes/List/Projects.js @@ -48,7 +48,11 @@ 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 d67fef72..fa8b6d12 100644 --- a/src/routes/List/TableList.js +++ b/src/routes/List/TableList.js @@ -312,7 +312,10 @@ export default class TableList extends PureComponent { } render() { - const { rule: { data }, loading } = this.props; + const { + rule: { data }, + loading, + } = this.props; const { selectedRows, modalVisible } = this.state; const columns = [ diff --git a/src/routes/Profile/AdvancedProfile.js b/src/routes/Profile/AdvancedProfile.js index cb0ccce9..0df2beae 100644 --- a/src/routes/Profile/AdvancedProfile.js +++ b/src/routes/Profile/AdvancedProfile.js @@ -333,7 +333,8 @@ export default class AdvancedProfile extends Component {
- 暂无数据 + + 暂无数据
- 您的账户已被冻结 + + 您的账户已被冻结 立即解冻
- 您的账户还不具备申请资格 + + 您的账户还不具备申请资格 立即升级 diff --git a/src/routes/Result/Success.js b/src/routes/Result/Success.js index 9e20e278..61263b56 100644 --- a/src/routes/Result/Success.js +++ b/src/routes/Result/Success.js @@ -15,7 +15,8 @@ const desc1 = ( }} >
- 曲丽丽 + 曲丽丽 +
2016-12-12 12:32
@@ -24,7 +25,8 @@ const desc1 = ( const desc2 = (
- 周毛毛 + 周毛毛 +
催一下 diff --git a/src/routes/User/RegisterResult.js b/src/routes/User/RegisterResult.js index 9c9bbe5f..3e86ee6e 100644 --- a/src/routes/User/RegisterResult.js +++ b/src/routes/User/RegisterResult.js @@ -23,7 +23,8 @@ export default ({ location }) => ( type="success" title={
- 你的账户:{location.state ? location.state.account : 'AntDesign@example.com'} 注册成功 + 你的账户: + {location.state ? location.state.account : 'AntDesign@example.com'} 注册成功
} description="激活邮件已发送到你的邮箱中,邮件有效期为24小时。请及时登录邮箱,点击邮件中的链接激活帐户。" From 2fa5a26573266735ee6ed94f0fcd88d34fc37435 Mon Sep 17 00:00:00 2001 From: Minqi Pan Date: Sun, 24 Jun 2018 14:59:42 +0800 Subject: [PATCH 29/31] stop re-assigning read-only "currentUser" --- src/components/GlobalHeader/index.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/components/GlobalHeader/index.js b/src/components/GlobalHeader/index.js index f84d2d2e..2befb2e2 100644 --- a/src/components/GlobalHeader/index.js +++ b/src/components/GlobalHeader/index.js @@ -68,9 +68,6 @@ export default class GlobalHeader extends PureComponent { onMenuClick, onNoticeClear, } = this.props; - if (currentUser == null) { - currentUser = {}; - } const menu = ( From 422c7207137c3bb4f6e10ce41b451eb8f76a0d6a Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 24 Jun 2018 15:07:01 +0800 Subject: [PATCH 30/31] fix falsy currentUser --- src/models/user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/user.js b/src/models/user.js index b45afc3a..214a7ca1 100644 --- a/src/models/user.js +++ b/src/models/user.js @@ -35,7 +35,7 @@ export default { saveCurrentUser(state, action) { return { ...state, - currentUser: action.payload, + currentUser: action.payload || {}, }; }, changeNotifyCount(state, action) { From 494a4681dcb9672f6d8175d9bb2e014388dff89a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Mon, 25 Jun 2018 08:41:43 +0800 Subject: [PATCH 31/31] Remove Authorized circular reference --- package.json | 9 +++---- src/components/Authorized/CheckPermissions.js | 2 +- src/components/Authorized/PromiseRender.js | 2 +- src/components/Authorized/index.js | 25 ++----------------- src/components/Authorized/renderAuthorize.js | 24 ++++++++++++++++++ 5 files changed, 32 insertions(+), 30 deletions(-) create mode 100644 src/components/Authorized/renderAuthorize.js diff --git a/package.json b/package.json index 7c8395da..ab41cfbd 100755 --- a/package.json +++ b/package.json @@ -23,9 +23,7 @@ "dependencies": { "@antv/data-set": "^0.8.0", "@babel/polyfill": "^7.0.0-beta.36", - "antd": "^3.4.3", - "babel-plugin-transform-decorators-legacy": "^1.3.4", - "babel-runtime": "^6.9.2", + "antd": "3.6.4", "bizcharts": "^3.1.10", "bizcharts-plugin-slider": "^2.0.1", "classnames": "^2.2.5", @@ -53,11 +51,12 @@ "babel-eslint": "^8.1.2", "babel-plugin-dva-hmr": "^0.4.1", "babel-plugin-import": "^1.6.7", + "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-module-resolver": "^3.1.1", "cross-env": "^5.1.1", "cross-port-killer": "^1.0.1", "enzyme": "^3.1.0", - "eslint": "^4.14.0", + "eslint": "^5.0.0", "eslint-config-airbnb": "^17.0.0", "eslint-config-prettier": "^2.9.0", "eslint-plugin-babel": "^5.1.0", @@ -73,7 +72,7 @@ "prettier": "1.13.5", "pro-download": "^1.0.1", "redbox-react": "^1.5.0", - "regenerator-runtime": "^0.11.1", + "regenerator-runtime": "^0.12.0", "roadhog": "^2.4.2", "roadhog-api-doc": "^1.0.3", "stylelint": "^9.2.1", diff --git a/src/components/Authorized/CheckPermissions.js b/src/components/Authorized/CheckPermissions.js index 06dc0ab9..a79e2859 100644 --- a/src/components/Authorized/CheckPermissions.js +++ b/src/components/Authorized/CheckPermissions.js @@ -1,6 +1,6 @@ import React from 'react'; import PromiseRender from './PromiseRender'; -import { CURRENT } from './index'; +import { CURRENT } from './renderAuthorize'; function isPromise(obj) { return ( diff --git a/src/components/Authorized/PromiseRender.js b/src/components/Authorized/PromiseRender.js index b18bcbec..292d3b1a 100644 --- a/src/components/Authorized/PromiseRender.js +++ b/src/components/Authorized/PromiseRender.js @@ -44,7 +44,7 @@ export default class PromiseRender extends React.PureComponent { }; render() { - const Component = this.state.component; + const { component: Component } = this.state; return Component ? ( ) : ( diff --git a/src/components/Authorized/index.js b/src/components/Authorized/index.js index 48d1b2b8..91eabf87 100644 --- a/src/components/Authorized/index.js +++ b/src/components/Authorized/index.js @@ -2,31 +2,10 @@ import Authorized from './Authorized'; import AuthorizedRoute from './AuthorizedRoute'; import Secured from './Secured'; import check from './CheckPermissions.js'; - -/* eslint-disable import/no-mutable-exports */ -let CURRENT = 'NULL'; +import renderAuthorize from './renderAuthorize'; Authorized.Secured = Secured; Authorized.AuthorizedRoute = AuthorizedRoute; Authorized.check = check; -/** - * use authority or getAuthority - * @param {string|()=>String} currentAuthority - */ -const renderAuthorize = currentAuthority => { - if (currentAuthority) { - if (currentAuthority.constructor.name === 'Function') { - CURRENT = currentAuthority(); - } - if (currentAuthority.constructor.name === 'String') { - CURRENT = currentAuthority; - } - } else { - CURRENT = 'NULL'; - } - return Authorized; -}; - -export { CURRENT }; -export default renderAuthorize; +export default renderAuthorize(Authorized); diff --git a/src/components/Authorized/renderAuthorize.js b/src/components/Authorized/renderAuthorize.js new file mode 100644 index 00000000..8e34c694 --- /dev/null +++ b/src/components/Authorized/renderAuthorize.js @@ -0,0 +1,24 @@ +/* eslint-disable import/no-mutable-exports */ +let CURRENT = 'NULL'; +/** + * use authority or getAuthority + * @param {string|()=>String} currentAuthority + */ +const renderAuthorize = Authorized => { + return currentAuthority => { + if (currentAuthority) { + if (currentAuthority.constructor.name === 'Function') { + CURRENT = currentAuthority(); + } + if (currentAuthority.constructor.name === 'String') { + CURRENT = currentAuthority; + } + } else { + CURRENT = 'NULL'; + } + return Authorized; + }; +}; + +export { CURRENT }; +export default Authorized => renderAuthorize(Authorized);