From 8cf518a865cfed307db8758b22914ac24a108c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=84=9A=E9=81=93?= Date: Wed, 29 Aug 2018 15:25:41 +0800 Subject: [PATCH] use airbnb eslint config and fix some rule --- .eslintignore | 2 +- .eslintrc.js | 19 ++- package.json | 1 - src/components/Authorized/CheckPermissions.js | 5 +- .../Authorized/CheckPermissions.test.js | 2 +- src/components/Authorized/index.js | 2 +- src/components/Authorized/renderAuthorize.js | 30 ++--- src/components/Charts/Gauge/index.js | 6 +- src/components/Charts/Pie/index.js | 5 +- src/components/Charts/autoHeight.js | 5 +- src/components/CountDown/index.js | 13 +- src/components/Ellipsis/index.js | 44 +++---- src/components/Ellipsis/index.test.js | 2 +- src/components/Exception/index.js | 2 + src/components/Login/LoginItem.js | 30 ++--- src/components/Login/LoginTab.js | 14 +- src/components/NoticeIcon/NoticeList.js | 1 + src/components/PageHeader/index.test.js | 14 +- src/components/SettingDrawer/BlockChecbox.js | 50 ++++--- src/components/SettingDrawer/ThemeColor.js | 42 +++--- src/components/SettingDrawer/index.js | 4 +- src/components/SiderMenu/BaseMenu.js | 14 +- src/components/SiderMenu/SliderMenu.js | 7 +- src/components/StandardTable/index.js | 12 +- src/components/TagSelect/index.js | 12 +- src/components/_utils/pathTools.js | 5 +- src/layouts/BasicLayout.js | 3 +- src/layouts/Header.js | 3 +- src/layouts/PageHeaderLayout.js | 36 +++--- src/pages/Account/Center/Articles.js | 3 +- src/pages/Account/Settings/BindingView.js | 66 +++++----- src/pages/Account/Settings/GeographicView.js | 12 +- src/pages/Account/Settings/SecurityView.js | 118 +++++++++-------- src/pages/Dashboard/Analysis.js | 13 +- src/pages/Dashboard/Workplace.js | 11 +- src/pages/Forms/TableForm.js | 11 +- src/pages/List/BasicList.js | 11 +- src/pages/List/TableList.js | 122 +++++++++--------- src/pages/User/Login.js | 11 +- src/pages/User/RegisterResult.js | 3 +- src/services/error.js | 2 +- src/utils/request.js | 19 +-- src/utils/utils.js | 5 +- 43 files changed, 376 insertions(+), 416 deletions(-) diff --git a/.eslintignore b/.eslintignore index 69f9854d..87467c1f 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1 @@ -/functions/mock \ No newline at end of file +/functions/mock diff --git a/.eslintrc.js b/.eslintrc.js index 9c1cf5f7..1a1c24b6 100755 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,5 +1,6 @@ module.exports = { - extends: ['eslint-config-umi', 'prettier'], + parser: 'babel-eslint', + extends: ['airbnb', 'prettier'], env: { browser: true, node: true, @@ -9,8 +10,20 @@ module.exports = { jasmine: true, }, rules: { - 'jsx-a11y/href-no-hash': [0], - 'react/sort-comp': 1, + 'react/jsx-filename-extension': [1, { extensions: ['.js'] }], + 'import/no-unresolved': 0, + 'jsx-a11y/anchor-is-valid': 0, + 'react/jsx-wrap-multilines': 0, + 'import/no-extraneous-dependencies': 0, + 'consistent-return': 0, + 'import/no-extraneous-dependencies': 0, + 'react/prop-types': 0, + 'jsx-a11y/click-events-have-key-events': 0, + 'jsx-a11y/no-static-element-interactions': 0, + 'react/prefer-stateless-function': 0, + 'jsx-a11y/no-noninteractive-element-interactions': 0, + 'react/forbid-prop-types': 0, + 'react/jsx-one-expression-per-line': 0, }, settings: { polyfills: ['fetch', 'promises'], diff --git a/package.json b/package.json index c4a07b73..9aee5e4d 100755 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ "eslint": "^5.4.0", "eslint-config-airbnb": "^17.0.0", "eslint-config-prettier": "^3.0.1", - "eslint-config-umi": "^0.1.4", "eslint-plugin-babel": "^5.1.0", "eslint-plugin-compat": "^2.5.1", "eslint-plugin-flowtype": "2.50.0", diff --git a/src/components/Authorized/CheckPermissions.js b/src/components/Authorized/CheckPermissions.js index 8aaad1ce..5bc225e3 100644 --- a/src/components/Authorized/CheckPermissions.js +++ b/src/components/Authorized/CheckPermissions.js @@ -82,8 +82,7 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => { export { checkPermissions }; -const check = (authority, target, Exception) => { - return checkPermissions(authority, CURRENT, target, Exception); -}; +const check = (authority, target, Exception) => + checkPermissions(authority, CURRENT, target, Exception); export default check; diff --git a/src/components/Authorized/CheckPermissions.test.js b/src/components/Authorized/CheckPermissions.test.js index 1e66cb9e..3988d85a 100644 --- a/src/components/Authorized/CheckPermissions.test.js +++ b/src/components/Authorized/CheckPermissions.test.js @@ -1,4 +1,4 @@ -import { checkPermissions } from './CheckPermissions.js'; +import { checkPermissions } from './CheckPermissions'; const target = 'ok'; const error = 'error'; diff --git a/src/components/Authorized/index.js b/src/components/Authorized/index.js index 91eabf87..22ac664d 100644 --- a/src/components/Authorized/index.js +++ b/src/components/Authorized/index.js @@ -1,7 +1,7 @@ import Authorized from './Authorized'; import AuthorizedRoute from './AuthorizedRoute'; import Secured from './Secured'; -import check from './CheckPermissions.js'; +import check from './CheckPermissions'; import renderAuthorize from './renderAuthorize'; Authorized.Secured = Secured; diff --git a/src/components/Authorized/renderAuthorize.js b/src/components/Authorized/renderAuthorize.js index 16177ede..5c5daa68 100644 --- a/src/components/Authorized/renderAuthorize.js +++ b/src/components/Authorized/renderAuthorize.js @@ -4,23 +4,21 @@ 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' || - currentAuthority.constructor.name === 'Array' - ) { - CURRENT = currentAuthority; - } - } else { - CURRENT = 'NULL'; +const renderAuthorize = Authorized => currentAuthority => { + if (currentAuthority) { + if (currentAuthority.constructor.name === 'Function') { + CURRENT = currentAuthority(); } - return Authorized; - }; + if ( + currentAuthority.constructor.name === 'String' || + currentAuthority.constructor.name === 'Array' + ) { + CURRENT = currentAuthority; + } + } else { + CURRENT = 'NULL'; + } + return Authorized; }; export { CURRENT }; diff --git a/src/components/Charts/Gauge/index.js b/src/components/Charts/Gauge/index.js index d9289eaa..093587d4 100644 --- a/src/components/Charts/Gauge/index.js +++ b/src/components/Charts/Gauge/index.js @@ -142,15 +142,13 @@ export default class Gauge extends React.Component { /> { - return ` + html={() => `

${title}

${data[0].value * 10}%

-
`; - }} + `} /> { if (value === '占比') { return color || 'rgba(24, 144, 255, 0.85)'; - } else { - return '#F0F2F5'; } + return '#F0F2F5'; }; data = [ @@ -257,7 +256,7 @@ export default class Pie extends Component { {item.x} - {`${(isNaN(item.percent) ? 0 : item.percent * 100).toFixed(2)}%`} + {`${(Number.isNaN(item.percent) ? 0 : item.percent * 100).toFixed(2)}%`} {valueFormat ? valueFormat(item.y) : item.y} diff --git a/src/components/Charts/autoHeight.js b/src/components/Charts/autoHeight.js index 01ae92dc..6ee9e098 100644 --- a/src/components/Charts/autoHeight.js +++ b/src/components/Charts/autoHeight.js @@ -30,8 +30,8 @@ function getAutoHeight(n) { return height; } -const autoHeight = () => WrappedComponent => { - return class extends React.Component { +const autoHeight = () => WrappedComponent => + class extends React.Component { state = { computedHeight: 0, }; @@ -58,6 +58,5 @@ const autoHeight = () => WrappedComponent => { ); } }; -}; export default autoHeight; diff --git a/src/components/CountDown/index.js b/src/components/CountDown/index.js index 53815c9e..7565bd82 100644 --- a/src/components/CountDown/index.js +++ b/src/components/CountDown/index.js @@ -23,6 +23,9 @@ const initTime = props => { }; class CountDown extends Component { + timer = 0; + + interval = 1000; constructor(props) { super(props); @@ -58,10 +61,6 @@ class CountDown extends Component { clearTimeout(this.timer); } - timer = 0; - - interval = 1000; - // defaultFormat = time => ( // {moment(time).format('hh:mm:ss')} // ); @@ -74,11 +73,7 @@ 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)} ); }; diff --git a/src/components/Ellipsis/index.js b/src/components/Ellipsis/index.js index 460361ef..1d9daf1a 100644 --- a/src/components/Ellipsis/index.js +++ b/src/components/Ellipsis/index.js @@ -13,16 +13,14 @@ const TooltipOverlayStyle = { wordWrap: 'break-word', }; -export const getStrFullLength = (str = '') => { - return str.split('').reduce((pre, cur) => { +export const getStrFullLength = (str = '') => + str.split('').reduce((pre, cur) => { const charCode = cur.charCodeAt(0); if (charCode >= 0 && charCode <= 128) { return pre + 1; - } else { - return pre + 2; } + return pre + 2; }, 0); -}; export const cutStrByFullLength = (str = '', maxLength) => { let showLength = 0; @@ -35,9 +33,8 @@ export const cutStrByFullLength = (str = '', maxLength) => { } if (showLength <= maxLength) { return pre + cur; - } else { - return pre; } + return pre; }, ''); }; @@ -139,29 +136,26 @@ export default class Ellipsis extends Component { sh = shadowNode.offsetHeight; if (sh > th || mid === begin) { return mid; - } else { - begin = mid; - if (end - begin === 1) { - mid = 1 + begin; - } else { - mid = Math.floor((end - begin) / 2) + begin; - } - return this.bisection(th, mid, begin, end, text, shadowNode); - } - } else { - if (mid - 1 < 0) { - return mid; } - shadowNode.innerHTML = text.substring(0, mid - 1) + suffix; - sh = shadowNode.offsetHeight; - if (sh <= th) { - return mid - 1; + begin = mid; + if (end - begin === 1) { + mid = 1 + begin; } else { - end = mid; mid = Math.floor((end - begin) / 2) + begin; - return this.bisection(th, mid, begin, end, text, shadowNode); } + return this.bisection(th, mid, begin, end, text, shadowNode); + } + if (mid - 1 < 0) { + return mid; + } + shadowNode.innerHTML = text.substring(0, mid - 1) + suffix; + sh = shadowNode.offsetHeight; + if (sh <= th) { + return mid - 1; } + end = mid; + mid = Math.floor((end - begin) / 2) + begin; + return this.bisection(th, mid, begin, end, text, shadowNode); }; handleRoot = n => { diff --git a/src/components/Ellipsis/index.test.js b/src/components/Ellipsis/index.test.js index ab454637..4d057b24 100644 --- a/src/components/Ellipsis/index.test.js +++ b/src/components/Ellipsis/index.test.js @@ -1,4 +1,4 @@ -import { getStrFullLength, cutStrByFullLength } from './index.js'; +import { getStrFullLength, cutStrByFullLength } from './index'; describe('test calculateShowLength', () => { it('get full length', () => { diff --git a/src/components/Exception/index.js b/src/components/Exception/index.js index d514cf8c..b358d11b 100644 --- a/src/components/Exception/index.js +++ b/src/components/Exception/index.js @@ -8,10 +8,12 @@ class Excrption extends React.PureComponent { static defaultProps = { backText: 'back to home', }; + constructor(props) { super(props); this.state = {}; } + render() { const { className, diff --git a/src/components/Login/LoginItem.js b/src/components/Login/LoginItem.js index c9a1a4f1..762964c2 100644 --- a/src/components/Login/LoginItem.js +++ b/src/components/Login/LoginItem.js @@ -122,22 +122,20 @@ class WarpFormItem extends Component { const LoginItem = {}; Object.keys(ItemMap).forEach(key => { const item = ItemMap[key]; - LoginItem[key] = props => { - return ( - - {context => ( - - )} - - ); - }; + LoginItem[key] = props => ( + + {context => ( + + )} + + ); }); export default LoginItem; diff --git a/src/components/Login/LoginTab.js b/src/components/Login/LoginTab.js index 0161caae..c50951c4 100644 --- a/src/components/Login/LoginTab.js +++ b/src/components/Login/LoginTab.js @@ -29,15 +29,11 @@ class LoginTab extends Component { } } -const warpContext = props => { - return ( - - {value => { - return ; - }} - - ); -}; +const warpContext = props => ( + + {value => } + +); // 标志位 用来判断是不是自定义组件 warpContext.typeName = 'LoginTab'; diff --git a/src/components/NoticeIcon/NoticeList.js b/src/components/NoticeIcon/NoticeList.js index 97b7e29f..7dc17868 100644 --- a/src/components/NoticeIcon/NoticeList.js +++ b/src/components/NoticeIcon/NoticeList.js @@ -28,6 +28,7 @@ export default function NoticeList({ const itemCls = classNames(styles.item, { [styles.read]: item.read, }); + // eslint-disable-next-line no-nested-ternary const leftIcon = item.avatar ? ( typeof item.avatar === 'string' ? ( diff --git a/src/components/PageHeader/index.test.js b/src/components/PageHeader/index.test.js index 5238ac55..e801a585 100644 --- a/src/components/PageHeader/index.test.js +++ b/src/components/PageHeader/index.test.js @@ -26,22 +26,18 @@ describe('test getBreadcrumb', () => { expect(getBreadcrumb(routerData, '/userinfo/2144/addr').name).toEqual('收货订单'); }); it('Loop through the parameters', () => { - const urlNameList = urlToList('/userinfo/2144/addr').map(url => { - return getBreadcrumb(routerData, url).name; - }); + const urlNameList = urlToList('/userinfo/2144/addr').map( + url => getBreadcrumb(routerData, url).name + ); expect(urlNameList).toEqual(['用户列表', '用户信息', '收货订单']); }); it('a path', () => { - const urlNameList = urlToList('/userinfo').map(url => { - return getBreadcrumb(routerData, url).name; - }); + const urlNameList = urlToList('/userinfo').map(url => getBreadcrumb(routerData, url).name); expect(urlNameList).toEqual(['用户列表']); }); it('Secondary path', () => { - const urlNameList = urlToList('/userinfo/2144').map(url => { - return getBreadcrumb(routerData, url).name; - }); + const urlNameList = urlToList('/userinfo/2144').map(url => getBreadcrumb(routerData, url).name); expect(urlNameList).toEqual(['用户列表', '用户信息']); }); }); diff --git a/src/components/SettingDrawer/BlockChecbox.js b/src/components/SettingDrawer/BlockChecbox.js index 2f05ec66..be7e3ff1 100644 --- a/src/components/SettingDrawer/BlockChecbox.js +++ b/src/components/SettingDrawer/BlockChecbox.js @@ -2,32 +2,28 @@ import { Icon } from 'antd'; import React from 'react'; import style from './index.less'; -const BlockChecbox = ({ value, onChange, list }) => { - return ( -
- {list.map(item => { - return ( -
{ - onChange(item.key); - }} - > - {item.key} -
- -
-
- ); - })} -
- ); -}; +const BlockChecbox = ({ value, onChange, list }) => ( +
+ {list.map(item => ( +
{ + onChange(item.key); + }} + > + {item.key} +
+ +
+
+ ))} +
+); export default BlockChecbox; diff --git a/src/components/SettingDrawer/ThemeColor.js b/src/components/SettingDrawer/ThemeColor.js index f70bd4f8..6246dc61 100644 --- a/src/components/SettingDrawer/ThemeColor.js +++ b/src/components/SettingDrawer/ThemeColor.js @@ -2,18 +2,16 @@ import { Icon } from 'antd'; import React from 'react'; import styles from './ThemeColor.less'; -const Tag = ({ color, check, ...rest }) => { - return ( -
- {check ? : ''} -
- ); -}; +const Tag = ({ color, check, ...rest }) => ( +
+ {check ? : ''} +
+); const ThemeColor = ({ colors, title, value, onChange }) => { let colorList = colors; @@ -33,17 +31,15 @@ const ThemeColor = ({ colors, title, value, onChange }) => {

{title}

- {colorList.map(color => { - return ( - onChange && onChange(color)} - /> - ); - })} + {colorList.map(color => ( + onChange && onChange(color)} + /> + ))}
); diff --git a/src/components/SettingDrawer/index.js b/src/components/SettingDrawer/index.js index fb299e01..5fe2ef67 100644 --- a/src/components/SettingDrawer/index.js +++ b/src/components/SettingDrawer/index.js @@ -76,9 +76,7 @@ class SettingDrawer extends PureComponent { />, ], }, - ].filter(item => { - return !item.hide; - }); + ].filter(item => !item.hide); }; changeSetting = (key, value) => { diff --git a/src/components/SiderMenu/BaseMenu.js b/src/components/SiderMenu/BaseMenu.js index a2922409..99485711 100644 --- a/src/components/SiderMenu/BaseMenu.js +++ b/src/components/SiderMenu/BaseMenu.js @@ -22,11 +22,8 @@ const getIcon = icon => { return icon; }; -export const getMenuMatches = (flatMenuKeys, path) => { - return flatMenuKeys.filter(item => { - return pathToRegexp(item).test(path); - }); -}; +export const getMenuMatches = (flatMenuKeys, path) => + flatMenuKeys.filter(item => pathToRegexp(item).test(path)); export default class BaseMenu extends PureComponent { constructor(props) { @@ -100,9 +97,8 @@ export default class BaseMenu extends PureComponent { {this.getNavMenuItems(item.children)} ); - } else { - return {this.getMenuItemPath(item)}; } + return {this.getMenuItemPath(item)}; }; /** @@ -143,6 +139,7 @@ export default class BaseMenu extends PureComponent { ); }; + // permission to check checkPermissionItem = (authority, ItemDom) => { const { Authorized } = this.props; @@ -156,9 +153,8 @@ export default class BaseMenu extends PureComponent { conversionPath = path => { if (path && path.indexOf('http') === 0) { return path; - } else { - return `/${path || ''}`.replace(/\/+/g, '/'); } + return `/${path || ''}`.replace(/\/+/g, '/'); }; render() { diff --git a/src/components/SiderMenu/SliderMenu.js b/src/components/SiderMenu/SliderMenu.js index 4be37551..ccbe5ea6 100644 --- a/src/components/SiderMenu/SliderMenu.js +++ b/src/components/SiderMenu/SliderMenu.js @@ -18,9 +18,7 @@ const getDefaultCollapsedSubMenus = props => { flatMenuKeys, } = props; return urlToList(pathname) - .map(item => { - return getMenuMatches(flatMenuKeys, item)[0]; - }) + .map(item => getMenuMatches(flatMenuKeys, item)[0]) .filter(item => item); }; @@ -69,6 +67,7 @@ export default class SiderMenu extends PureComponent { } return null; } + isMainMenu = key => { const { menuData } = this.props; return menuData.some(item => { @@ -78,12 +77,14 @@ export default class SiderMenu extends PureComponent { return false; }); }; + handleOpenChange = openKeys => { const moreThanOne = openKeys.filter(openKey => this.isMainMenu(openKey)).length > 1; this.setState({ openKeys: moreThanOne ? [openKeys.pop()] : [...openKeys], }); }; + render() { const { logo, collapsed, onCollapse, fixSiderbar, theme } = this.props; const { openKeys } = this.state; diff --git a/src/components/StandardTable/index.js b/src/components/StandardTable/index.js index 14b4984d..9e8c85ad 100644 --- a/src/components/StandardTable/index.js +++ b/src/components/StandardTable/index.js @@ -38,14 +38,10 @@ class StandardTable extends PureComponent { handleRowSelectChange = (selectedRowKeys, selectedRows) => { let { needTotalList } = this.state; - needTotalList = needTotalList.map(item => { - return { - ...item, - total: selectedRows.reduce((sum, val) => { - return sum + parseFloat(val[item.dataIndex], 10); - }, 0), - }; - }); + needTotalList = needTotalList.map(item => ({ + ...item, + total: selectedRows.reduce((sum, val) => sum + parseFloat(val[item.dataIndex], 10), 0), + })); const { onSelectRow } = this.props; if (onSelectRow) { onSelectRow(selectedRows); diff --git a/src/components/TagSelect/index.js b/src/components/TagSelect/index.js index dff38242..c36cd672 100644 --- a/src/components/TagSelect/index.js +++ b/src/components/TagSelect/index.js @@ -18,6 +18,7 @@ class TagSelect extends Component { static defaultProps = { hideCheckAll: false, }; + constructor(props) { super(props); this.state = { @@ -80,13 +81,10 @@ class TagSelect extends Component { }); }; - isTagSelectOption = node => { - return ( - node && - node.type && - (node.type.isTagSelectOption || node.type.displayName === 'TagSelectOption') - ); - }; + isTagSelectOption = node => + node && + node.type && + (node.type.isTagSelectOption || node.type.displayName === 'TagSelectOption'); render() { const { value, expand } = this.state; diff --git a/src/components/_utils/pathTools.js b/src/components/_utils/pathTools.js index 7d49400a..bfb94e74 100644 --- a/src/components/_utils/pathTools.js +++ b/src/components/_utils/pathTools.js @@ -1,7 +1,6 @@ // /userinfo/2144/id => ['/userinfo','/useinfo/2144,'/userindo/2144/id'] +// eslint-disable-next-line import/prefer-default-export export function urlToList(url) { const urllist = url.split('/').filter(i => i); - return urllist.map((urlItem, index) => { - return `/${urllist.slice(0, index + 1).join('/')}`; - }); + return urllist.map((urlItem, index) => `/${urllist.slice(0, index + 1).join('/')}`); } diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 9754ebd2..e949f527 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -174,6 +174,7 @@ class BasicLayout extends React.PureComponent { children, location: { pathname }, } = this.props; + const { rendering } = this.state; const isTop = PropsLayout === 'topmenu'; const layout = ( @@ -209,7 +210,7 @@ class BasicLayout extends React.PureComponent { )} - {this.state.rendering && process.env.NODE_ENV === 'production' ? null : ( // Do show SettingDrawer in production + {rendering && process.env.NODE_ENV === 'production' ? null : ( // Do show SettingDrawer in production )} diff --git a/src/layouts/Header.js b/src/layouts/Header.js index 77825be4..3229daf9 100644 --- a/src/layouts/Header.js +++ b/src/layouts/Header.js @@ -71,7 +71,7 @@ class HeaderView extends PureComponent { } }; - handScroll = e => { + handScroll = () => { const { autoHideHeader } = this.props; const { visible } = this.state; if (!autoHideHeader) { @@ -99,7 +99,6 @@ class HeaderView extends PureComponent { } this.oldScrollTop = scrollTop; this.ticking = false; - return; }); } this.ticking = false; diff --git a/src/layouts/PageHeaderLayout.js b/src/layouts/PageHeaderLayout.js index 9b8ae660..a3f51c59 100644 --- a/src/layouts/PageHeaderLayout.js +++ b/src/layouts/PageHeaderLayout.js @@ -2,33 +2,31 @@ import React from 'react'; import { FormattedMessage } from 'umi/locale'; import Link from 'umi/link'; import PageHeader from '@/components/PageHeader'; +import { connect } from 'dva'; import GridContent from './GridContent'; import styles from './PageHeaderLayout.less'; import MenuContext from './MenuContext'; -import { connect } from 'dva'; const PageHeaderLayout = ({ children, grid, wrapperClassName, top, ...restProps }) => (
{top} - {value => { - return ( - } - {...value} - key="pageheader" - {...restProps} - linkElement={Link} - itemRender={item => { - if (item.locale) { - return ; - } - return item.name; - }} - /> - ); - }} + {value => ( + } + {...value} + key="pageheader" + {...restProps} + linkElement={Link} + itemRender={item => { + if (item.locale) { + return ; + } + return item.name; + }} + /> + )} {children ? (
diff --git a/src/pages/Account/Center/Articles.js b/src/pages/Account/Center/Articles.js index 610b36c9..ece18617 100644 --- a/src/pages/Account/Center/Articles.js +++ b/src/pages/Account/Center/Articles.js @@ -24,7 +24,8 @@ export default class Center extends PureComponent {
{content}
- {owner} 发布在 {href} + {owner} 发布在 + {href} {moment(updatedAt).format('YYYY-MM-DD HH:mm')}
diff --git a/src/pages/Account/Settings/BindingView.js b/src/pages/Account/Settings/BindingView.js index 081ce9a1..1080e350 100644 --- a/src/pages/Account/Settings/BindingView.js +++ b/src/pages/Account/Settings/BindingView.js @@ -3,40 +3,38 @@ import { formatMessage, FormattedMessage } from 'umi/locale'; import { Icon, List } from 'antd'; class BindingView extends Component { - getData = () => { - return [ - { - title: formatMessage({ id: 'app.settings.binding.taobao' }, {}), - description: formatMessage({ id: 'app.settings.binding.taobao-description' }, {}), - actions: [ - - - , - ], - avatar: , - }, - { - title: formatMessage({ id: 'app.settings.binding.alipay' }, {}), - description: formatMessage({ id: 'app.settings.binding.alipay-description' }, {}), - actions: [ - - - , - ], - avatar: , - }, - { - title: formatMessage({ id: 'app.settings.binding.dingding' }, {}), - description: formatMessage({ id: 'app.settings.binding.dingding-description' }, {}), - actions: [ - - - , - ], - avatar: , - }, - ]; - }; + getData = () => [ + { + title: formatMessage({ id: 'app.settings.binding.taobao' }, {}), + description: formatMessage({ id: 'app.settings.binding.taobao-description' }, {}), + actions: [ + + + , + ], + avatar: , + }, + { + title: formatMessage({ id: 'app.settings.binding.alipay' }, {}), + description: formatMessage({ id: 'app.settings.binding.alipay-description' }, {}), + actions: [ + + + , + ], + avatar: , + }, + { + title: formatMessage({ id: 'app.settings.binding.dingding' }, {}), + description: formatMessage({ id: 'app.settings.binding.dingding-description' }, {}), + actions: [ + + + , + ], + avatar: , + }, + ]; render() { return ( diff --git a/src/pages/Account/Settings/GeographicView.js b/src/pages/Account/Settings/GeographicView.js index dab3a980..b4f7a99b 100644 --- a/src/pages/Account/Settings/GeographicView.js +++ b/src/pages/Account/Settings/GeographicView.js @@ -55,13 +55,11 @@ export default class GeographicView extends PureComponent { ); } - return list.map(item => { - return ( - - ); - }); + return list.map(item => ( + + )); }; selectProvinceItem = item => { diff --git a/src/pages/Account/Settings/SecurityView.js b/src/pages/Account/Settings/SecurityView.js index a58766b3..97cde061 100644 --- a/src/pages/Account/Settings/SecurityView.js +++ b/src/pages/Account/Settings/SecurityView.js @@ -23,66 +23,64 @@ const passwordStrength = { }; class SecurityView extends Component { - getData = () => { - return [ - { - title: formatMessage({ id: 'app.settings.security.password' }, {}), - description: ( - - {formatMessage({ id: 'app.settings.security.password-description' }, {})}: - {passwordStrength.strong} - - ), - actions: [ - - - , - ], - }, - { - title: formatMessage({ id: 'app.settings.security.phone' }, {}), - description: `${formatMessage( - { id: 'app.settings.security.phone-description' }, - {} - )}:138****8293`, - actions: [ - - - , - ], - }, - { - title: formatMessage({ id: 'app.settings.security.question' }, {}), - description: formatMessage({ id: 'app.settings.security.question-description' }, {}), - actions: [ - - - , - ], - }, - { - title: formatMessage({ id: 'app.settings.security.email' }, {}), - description: `${formatMessage( - { id: 'app.settings.security.email-description' }, - {} - )}:ant***sign.com`, - actions: [ - - - , - ], - }, - { - title: formatMessage({ id: 'app.settings.security.mfa' }, {}), - description: formatMessage({ id: 'app.settings.security.mfa-description' }, {}), - actions: [ - - - , - ], - }, - ]; - }; + getData = () => [ + { + title: formatMessage({ id: 'app.settings.security.password' }, {}), + description: ( + + {formatMessage({ id: 'app.settings.security.password-description' }, {})}: + {passwordStrength.strong} + + ), + actions: [ + + + , + ], + }, + { + title: formatMessage({ id: 'app.settings.security.phone' }, {}), + description: `${formatMessage( + { id: 'app.settings.security.phone-description' }, + {} + )}:138****8293`, + actions: [ + + + , + ], + }, + { + title: formatMessage({ id: 'app.settings.security.question' }, {}), + description: formatMessage({ id: 'app.settings.security.question-description' }, {}), + actions: [ + + + , + ], + }, + { + title: formatMessage({ id: 'app.settings.security.email' }, {}), + description: `${formatMessage( + { id: 'app.settings.security.email-description' }, + {} + )}:ant***sign.com`, + actions: [ + + + , + ], + }, + { + title: formatMessage({ id: 'app.settings.security.mfa' }, {}), + description: formatMessage({ id: 'app.settings.security.mfa-description' }, {}), + actions: [ + + + , + ], + }, + ]; render() { return ( diff --git a/src/pages/Dashboard/Analysis.js b/src/pages/Dashboard/Analysis.js index 62679aa8..b7f7e6ba 100644 --- a/src/pages/Dashboard/Analysis.js +++ b/src/pages/Dashboard/Analysis.js @@ -157,13 +157,12 @@ class Analysis extends Component { salesTypeDataOffline, } = chart; const loading = propsLoding || stateLoading; - const salesPieData = - salesType === 'all' - ? salesTypeData - : salesType === 'online' - ? salesTypeDataOnline - : salesTypeDataOffline; - + let salesPieData; + if (salesType === 'all') { + salesPieData = salesTypeData; + } else { + salesPieData = salesType === 'online' ? salesTypeDataOnline : salesTypeDataOffline; + } const menu = ( 操作一 diff --git a/src/pages/Dashboard/Workplace.js b/src/pages/Dashboard/Workplace.js index 6d6e73a3..0b79072d 100644 --- a/src/pages/Dashboard/Workplace.js +++ b/src/pages/Dashboard/Workplace.js @@ -124,9 +124,13 @@ export default class Workplace extends PureComponent {
-
早安,{currentUser.name},祝你开心每一天!
+
+ 早安, + {currentUser.name} + ,祝你开心每一天! +
- {currentUser.title} | {currentUser.group} + {currentUser.title} |{currentUser.group}
@@ -141,8 +145,7 @@ export default class Workplace extends PureComponent {

团队内排名

- 8 - / 24 + 8 / 24

diff --git a/src/pages/Forms/TableForm.js b/src/pages/Forms/TableForm.js index 3ad0a791..dc590fc5 100644 --- a/src/pages/Forms/TableForm.js +++ b/src/pages/Forms/TableForm.js @@ -4,6 +4,9 @@ import isEqual from 'lodash.isequal'; import styles from './style.less'; export default class TableForm extends PureComponent { + index = 0; + + cacheOriginData = {}; constructor(props) { super(props); @@ -26,10 +29,6 @@ export default class TableForm extends PureComponent { }; } - index = 0; - - cacheOriginData = {}; - getRowByKey(key, newData) { const { data } = this.state; return (newData || data).filter(item => item.key === key)[0]; @@ -244,9 +243,7 @@ export default class TableForm extends PureComponent { columns={columns} dataSource={data} pagination={false} - rowClassName={record => { - return record.editable ? styles.editable : ''; - }} + rowClassName={record => (record.editable ? styles.editable : '')} />