From 6225aa6d57b90c141ed9a1aeb43312aa1e5166f7 Mon Sep 17 00:00:00 2001 From: ws456999 Date: Fri, 23 Mar 2018 11:44:09 +0800 Subject: [PATCH 1/8] :bug: fix inner exact cover custom exact bug (#1148) --- 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 93fb54f4..cd37af42 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -141,10 +141,10 @@ export function getRoutes(path, routerData) { const renderRoutes = renderArr.map((item) => { const exact = !routes.some(route => route !== item && getRelation(route, item) === 1); return { + exact, ...routerData[`${path}${item}`], key: `${path}${item}`, path: `${path}${item}`, - exact, }; }); return renderRoutes; From 9a34d47c66ffd35ec341eb755ccf6b3417f09a5a Mon Sep 17 00:00:00 2001 From: Reed Sun Date: Sat, 24 Mar 2018 12:06:35 +0800 Subject: [PATCH 2/8] Improve the display of bread crumbs (#1053) * Improve the display of bread crumbs * unuse template literals --- src/layouts/BasicLayout.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 60339b99..6ee29894 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -38,6 +38,25 @@ const getRedirect = (item) => { }; getMenuData().forEach(getRedirect); +/** + * 获取面包屑映射 + * @param {Object} menuData 菜单配置 + * @param {Object} routerData 路由配置 + */ +const getBreadcrumbNameMap = (menuData, routerData) => { + const result = {}; + const childResult = {}; + for (const i of menuData) { + if (!routerData[i.path]) { + result[i.path] = i; + } + if (i.children) { + Object.assign(childResult, getBreadcrumbNameMap(i.children, routerData)); + } + } + return Object.assign({}, routerData, result, childResult); +}; + const query = { 'screen-xs': { maxWidth: 575, @@ -76,7 +95,7 @@ class BasicLayout extends React.PureComponent { const { location, routerData } = this.props; return { location, - breadcrumbNameMap: routerData, + breadcrumbNameMap: getBreadcrumbNameMap(getMenuData(), routerData), }; } componentDidMount() { From 148aaa89355b04e98eb8a256a80e7d0ed159806e Mon Sep 17 00:00:00 2001 From: ddcat1115 Date: Sat, 24 Mar 2018 13:50:30 +0800 Subject: [PATCH 3/8] let `hideInBreadcrumb` available in menu.js --- src/common/menu.js | 1 + src/common/router.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/common/menu.js b/src/common/menu.js index 50f8a464..a5da89ad 100644 --- a/src/common/menu.js +++ b/src/common/menu.js @@ -13,6 +13,7 @@ const menuData = [{ }, { name: '工作台', path: 'workplace', + // hideInBreadcrumb: true, // hideInMenu: true, }], }, { diff --git a/src/common/router.js b/src/common/router.js index c27e9d4d..60235976 100644 --- a/src/common/router.js +++ b/src/common/router.js @@ -192,6 +192,7 @@ export const getRouterData = (app) => { ...router, name: router.name || menuItem.name, authority: router.authority || menuItem.authority, + hideInBreadcrumb: router.hideInBreadcrumb || menuItem.hideInBreadcrumb, }; routerData[path] = router; }); From 4f9d8ce08c224539d5b47b70037984e23d09a24b Mon Sep 17 00:00:00 2001 From: ddcat1115 Date: Sat, 24 Mar 2018 14:07:57 +0800 Subject: [PATCH 4/8] remove useless setting --- src/routes/Dashboard/Monitor.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/routes/Dashboard/Monitor.js b/src/routes/Dashboard/Monitor.js index 07bbae85..c6787b63 100644 --- a/src/routes/Dashboard/Monitor.js +++ b/src/routes/Dashboard/Monitor.js @@ -82,20 +82,6 @@ export default class Monitor extends PureComponent { bordered={false} > { - switch (parseInt(val, 10)) { - case 20: - return '差'; - case 40: - return '中'; - case 60: - return '良'; - case 80: - return '优'; - default: - return ''; - } - }} title="跳出率" height={180} percent={87} From 9dcebdc2c94894dc358dcbb31d8fdfdf11c38d4a Mon Sep 17 00:00:00 2001 From: ddcat1115 Date: Sun, 25 Mar 2018 01:03:02 +0800 Subject: [PATCH 5/8] fix #948 --- src/routes/List/CardList.less | 2 ++ src/routes/List/Projects.less | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/routes/List/CardList.less b/src/routes/List/CardList.less index c4c2e573..7493f36e 100644 --- a/src/routes/List/CardList.less +++ b/src/routes/List/CardList.less @@ -10,6 +10,8 @@ margin-bottom: 12px; & > a { color: @heading-color; + display: inline-block; + max-width: 100%; } } .ant-card-actions { diff --git a/src/routes/List/Projects.less b/src/routes/List/Projects.less index 890a1ad2..93a8b448 100644 --- a/src/routes/List/Projects.less +++ b/src/routes/List/Projects.less @@ -10,6 +10,8 @@ margin-bottom: 4px; & > a { color: @heading-color; + display: inline-block; + max-width: 100%; } } .ant-card-meta-description { From fc178e55d95844d18a92d11b8040e46ab96ef008 Mon Sep 17 00:00:00 2001 From: niko <644506165@qq.com> Date: Sun, 25 Mar 2018 02:09:56 +0800 Subject: [PATCH 6/8] Fixed: #1142 (#1160) * fixed: #1142 * fix typo * fix typo * fix typo * add missing fix --- src/components/Charts/ChartCard/index.d.ts | 2 +- src/components/Charts/ChartCard/index.js | 59 +++++++++++---------- src/components/Charts/Pie/index.d.ts | 4 +- src/components/Charts/Pie/index.js | 11 ++-- src/components/Charts/demo/chart-card.md | 60 ++++++++++++++++------ src/components/Charts/demo/mix.md | 1 + src/components/Charts/demo/pie.md | 19 ++++--- src/components/Charts/index.md | 4 +- src/routes/Dashboard/Analysis.js | 12 +++-- 9 files changed, 106 insertions(+), 66 deletions(-) diff --git a/src/components/Charts/ChartCard/index.d.ts b/src/components/Charts/ChartCard/index.d.ts index 76470460..ad450dfa 100644 --- a/src/components/Charts/ChartCard/index.d.ts +++ b/src/components/Charts/ChartCard/index.d.ts @@ -2,7 +2,7 @@ import * as React from "react"; export interface IChartCardProps { title: React.ReactNode; action?: React.ReactNode; - total?: React.ReactNode | number; + total?: React.ReactNode | function | number; footer?: React.ReactNode; contentHeight?: number; avatar?: React.ReactNode; diff --git a/src/components/Charts/ChartCard/index.js b/src/components/Charts/ChartCard/index.js index 2fd10e6f..035b3131 100644 --- a/src/components/Charts/ChartCard/index.js +++ b/src/components/Charts/ChartCard/index.js @@ -10,8 +10,8 @@ const renderTotal = (total) => { case undefined: totalDom = null; break; - case 'string': - totalDom =
; + case 'function': + totalDom =
{total()}
; break; default: totalDom =
{total}
; @@ -20,18 +20,22 @@ const renderTotal = (total) => { }; const ChartCard = ({ - loading = false, contentHeight, title, avatar, action, total, footer, children, ...rest + loading = false, + contentHeight, + title, + avatar, + action, + total, + footer, + children, + ...rest }) => { const content = (
-
- { - avatar - } -
+
{avatar}
{title} @@ -40,31 +44,26 @@ const ChartCard = ({ {renderTotal(total)}
- { - children && ( -
-
- {children} -
-
- ) - } - { - footer && ( -
- {footer} -
- ) - } + {children && ( +
+
{children}
+
+ )} + {footer && ( +
+ {footer} +
+ )}
); return ( - - {{content}} + + { + + {content} + + } ); }; diff --git a/src/components/Charts/Pie/index.d.ts b/src/components/Charts/Pie/index.d.ts index e9dcd1d4..5b19208d 100644 --- a/src/components/Charts/Pie/index.d.ts +++ b/src/components/Charts/Pie/index.d.ts @@ -10,10 +10,10 @@ export interface IPieProps { x: string | string; y: number; }>; - total?: string; + total?: string | function; title?: React.ReactNode; tooltip?: boolean; - valueFormat?: (value: string) => string; + valueFormat?: (value: string) => string | React.ReactNode; subTitle?: React.ReactNode; } diff --git a/src/components/Charts/Pie/index.js b/src/components/Charts/Pie/index.js index 528b2519..2784ad60 100644 --- a/src/components/Charts/Pie/index.js +++ b/src/components/Charts/Pie/index.js @@ -221,7 +221,9 @@ export default class Pie extends Component {
{subTitle &&

{subTitle}

} {/* eslint-disable-next-line */} - {total &&
} + {total && ( +
{typeof total === 'function' ? total() : total}
+ )}
)}
@@ -240,12 +242,7 @@ export default class Pie extends Component { {`${(isNaN(item.percent) ? 0 : item.percent * 100).toFixed(2)}%`} - + {valueFormat ? valueFormat(item.y) : item.y} ))} diff --git a/src/components/Charts/demo/chart-card.md b/src/components/Charts/demo/chart-card.md index 51204793..4da852b7 100644 --- a/src/components/Charts/demo/chart-card.md +++ b/src/components/Charts/demo/chart-card.md @@ -5,7 +5,7 @@ title: 图表卡片 用于展示图表的卡片容器,可以方便的配合其它图表套件展示丰富信息。 -````jsx +```jsx import { ChartCard, yuan, Field } from 'ant-design-pro/lib/Charts'; import Trend from 'ant-design-pro/lib/Trend'; import { Row, Col, Icon, Tooltip } from 'antd'; @@ -16,18 +16,33 @@ ReactDOM.render( } - total={yuan(126560)} - footer={} + action={ + + + + } + total={() => ( + + )} + footer={ + + } contentHeight={46} > 周同比 - 12% + + 12% + 日环比 - 11% + + 11% + @@ -41,25 +56,40 @@ ReactDOM.render( alt="indicator" /> } - action={} - total={yuan(126560)} - footer={} + action={ + + + + } + total={() => ( + + )} + footer={ + + } /> + } + action={ + + + + } + total={() => ( + )} - action={} - total={yuan(126560)} /> - -, mountNode); -```` + , + mountNode, +); +``` diff --git a/src/components/Charts/demo/mix.md b/src/components/Charts/demo/mix.md index 0c158e5f..fc64110a 100644 --- a/src/components/Charts/demo/mix.md +++ b/src/components/Charts/demo/mix.md @@ -27,6 +27,7 @@ ReactDOM.render( now.y + pre, 0))} + total={() => ( + now.y + pre, 0)) + }} + /> + )} data={salesPieData} - valueFormat={val => yuan(val)} + valueFormat={val => } height={294} - /> -, mountNode); -```` + />, + mountNode, +); +``` diff --git a/src/components/Charts/index.md b/src/components/Charts/index.md index e48220e5..e292a247 100644 --- a/src/components/Charts/index.md +++ b/src/components/Charts/index.md @@ -19,7 +19,7 @@ Ant Design Pro 提供的业务中常用的图表类型,都是基于 [G2](https |----------|------------------------------------------|-------------|-------| | title | 卡片标题 | ReactNode\|string | - | | action | 卡片操作 | ReactNode | - | -| total | 数据总量 | ReactNode \| number | - | +| total | 数据总量 | ReactNode \| number \| function | - | | footer | 卡片底部 | ReactNode | - | | contentHeight | 内容区域高度 | number | - | | avatar | 右侧图标 | React.ReactNode | - | @@ -78,7 +78,7 @@ Ant Design Pro 提供的业务中常用的图表类型,都是基于 [G2](https | valueFormat | 显示值的格式化函数 | function | - | | title | 图表标题 | ReactNode\|string | - | | subTitle | 图表子标题 | ReactNode\|string | - | -| total | 图标中央的总数 | string | - | +| total | 图标中央的总数 | string | function | - | ### Radar diff --git a/src/routes/Dashboard/Analysis.js b/src/routes/Dashboard/Analysis.js index 9cb55a9a..b7582b03 100644 --- a/src/routes/Dashboard/Analysis.js +++ b/src/routes/Dashboard/Analysis.js @@ -252,7 +252,7 @@ export default class Analysis extends Component { } - total={yuan(126560)} + total={() => } footer={} contentHeight={46} > @@ -451,9 +451,15 @@ export default class Analysis extends Component { now.y + pre, 0))} + total={() => ( + now.y + pre, 0)), + }} + /> + )} data={salesPieData} - valueFormat={val => yuan(val)} + valueFormat={val => } height={248} lineWidth={4} /> From 9bc3e710815d4a1defb73827be7f77f3c1fa3336 Mon Sep 17 00:00:00 2001 From: ddcat1115 Date: Sun, 25 Mar 2018 20:29:53 +0800 Subject: [PATCH 7/8] bump 1.2.0 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 44dec94f..991e563f 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ant-design-pro", - "version": "1.1.0", + "version": "1.2.0", "description": "An out-of-box UI solution for enterprise applications", "private": true, "scripts": { @@ -83,7 +83,7 @@ "**/*.less": "stylelint --syntax less" }, "engines": { - "node" : ">=8.0.0" + "node": ">=8.0.0" }, "browserslist": [ "> 1%", From 420b297630e6323eafdd2d2501a4a536083e1c31 Mon Sep 17 00:00:00 2001 From: ddcat1115 Date: Sun, 25 Mar 2018 22:19:06 +0800 Subject: [PATCH 8/8] temp fix: roadhog test failed with alias set --- .babelrc.js | 12 ++++++++++++ package.json | 1 + 2 files changed, 13 insertions(+) create mode 100644 .babelrc.js diff --git a/.babelrc.js b/.babelrc.js new file mode 100644 index 00000000..96df8001 --- /dev/null +++ b/.babelrc.js @@ -0,0 +1,12 @@ +module.exports = { + plugins: [ + [ + 'babel-plugin-module-resolver', + { + alias: { + components: './src/components', + }, + }, + ], + ], +}; \ No newline at end of file diff --git a/package.json b/package.json index 991e563f..572201ad 100755 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "babel-eslint": "^8.1.2", "babel-plugin-dva-hmr": "^0.4.1", "babel-plugin-import": "^1.6.7", + "babel-plugin-module-resolver": "^3.1.1", "babel-plugin-transform-decorators-legacy": "^1.3.4", "cross-env": "^5.1.1", "cross-port-killer": "^1.0.1",