From 9524ea8e61df23b1446f6aa9a13dc0fad8a15dc0 Mon Sep 17 00:00:00 2001 From: chsword Date: Fri, 6 Nov 2020 13:02:26 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix:=20breadcrumb=E4=B8=ADitemRender=20slot?= =?UTF-8?q?=E7=9A=84=E5=8F=82=E6=95=B0=E4=B8=8E=E5=AE=9A=E4=B9=89=E4=B8=8E?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E7=9A=84=E4=B8=8D=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/breadcrumb/Breadcrumb.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/breadcrumb/Breadcrumb.tsx b/components/breadcrumb/Breadcrumb.tsx index a9242451f5..34f427d025 100644 --- a/components/breadcrumb/Breadcrumb.tsx +++ b/components/breadcrumb/Breadcrumb.tsx @@ -20,7 +20,7 @@ const BreadcrumbProps = { separator: PropTypes.VNodeChild, itemRender: { type: Function as PropType< - (route: Route, params: any, routes: Array, paths: Array) => VueNode + (opt: { route: Route; params: any; routes: Array; paths: Array }) => VueNode >, }, }; From d0311d3eeec4425a66bb4db411de545a61417197 Mon Sep 17 00:00:00 2001 From: Zou Jian Date: Sat, 7 Nov 2020 23:51:03 +0800 Subject: [PATCH 2/6] Update components/breadcrumb/Breadcrumb.tsx Co-authored-by: Amour1688 <31695475+Amour1688@users.noreply.github.com> --- components/breadcrumb/Breadcrumb.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/breadcrumb/Breadcrumb.tsx b/components/breadcrumb/Breadcrumb.tsx index 34f427d025..c9208ac740 100644 --- a/components/breadcrumb/Breadcrumb.tsx +++ b/components/breadcrumb/Breadcrumb.tsx @@ -20,7 +20,7 @@ const BreadcrumbProps = { separator: PropTypes.VNodeChild, itemRender: { type: Function as PropType< - (opt: { route: Route; params: any; routes: Array; paths: Array }) => VueNode + (opt: { route: Route; params: any; routes: Route[]; paths: string[] }) => VueNode >, }, }; From 4c4ee9a2ef35573718067a9e47ae14d65f84f0de Mon Sep 17 00:00:00 2001 From: chsword Date: Wed, 11 Nov 2020 11:04:20 +0800 Subject: [PATCH 3/6] =?UTF-8?q?fix:=20=F0=9F=90=9E=20tsx=20=E4=B8=AD?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=20Descriptions.Item=20=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/descriptions/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/descriptions/index.tsx b/components/descriptions/index.tsx index 2e618d0911..4b6d357d8f 100644 --- a/components/descriptions/index.tsx +++ b/components/descriptions/index.tsx @@ -30,7 +30,7 @@ export const DescriptionsItemProps = { span: PropTypes.number, }; -export const DescriptionsItem = { +export const DescriptionsItem = defineComponent({ name: 'ADescriptionsItem', props: { prefixCls: PropTypes.string, @@ -40,7 +40,7 @@ export const DescriptionsItem = { render() { return null; }, -}; +}); const DEFAULT_COLUMN_MAP: Record = { xxl: 3, From fd601aea0b5de05cfe6761236b950a3473ef91b0 Mon Sep 17 00:00:00 2001 From: chsword Date: Sat, 14 Nov 2020 00:51:09 +0800 Subject: [PATCH 4/6] =?UTF-8?q?fix:=20=F0=9F=90=9E=20Statistic.Countdown?= =?UTF-8?q?=20=E5=8A=A8=E7=94=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/statistic/Number.tsx | 105 ++++++++++++++++++----------- components/statistic/Statistic.tsx | 6 +- 2 files changed, 68 insertions(+), 43 deletions(-) diff --git a/components/statistic/Number.tsx b/components/statistic/Number.tsx index eb7d65a7e1..de92b30517 100644 --- a/components/statistic/Number.tsx +++ b/components/statistic/Number.tsx @@ -1,53 +1,76 @@ import padEnd from 'lodash-es/padEnd'; -import { FunctionalComponent, VNodeTypes } from 'vue'; +import { defineComponent, PropType, VNodeTypes } from 'vue'; import { FormatConfig, valueType } from './utils'; +import initDefaultProps from '../_util/props-util/initDefaultProps'; interface NumberProps extends FormatConfig { value: valueType; } +import PropTypes from '../_util/vue-types'; +import { countdownValueType } from './utils'; +export const NumberProps = { + prefixCls: PropTypes.string, + decimalSeparator: PropTypes.string, + groupSeparator: PropTypes.string, + format: PropTypes.string, + value: { + type: [String, Number, Object] as PropType, + }, -const Number: FunctionalComponent = props => { - const { value, formatter, precision, decimalSeparator, groupSeparator = '', prefixCls } = props; - let valueNode: VNodeTypes; - - if (typeof formatter === 'function') { - // Customize formatter - valueNode = formatter({ value }); - } else { - // Internal formatter - const val = String(value); - const cells = val.match(/^(-?)(\d*)(\.(\d+))?$/); - // Process if illegal number - if (!cells) { - valueNode = val; + valueRender: PropTypes.any, + formatter: PropTypes.any, + precision: PropTypes.number, +}; +const StatisticNumber = defineComponent({ + props: initDefaultProps(NumberProps, {}), + render() { + const { + value, + formatter, + precision, + decimalSeparator, + groupSeparator = '', + prefixCls, + } = this.$props; + let valueNode: VNodeTypes; + if (typeof formatter === 'function') { + // Customize formatter + valueNode = formatter({ value }); } else { - const negative = cells[1]; - let int = cells[2] || '0'; - let decimal = cells[4] || ''; + // Internal formatter + const val = String(value); + const cells = val.match(/^(-?)(\d*)(\.(\d+))?$/); + // Process if illegal number + if (!cells) { + valueNode = val; + } else { + const negative = cells[1]; + let int = cells[2] || '0'; + let decimal = cells[4] || ''; - int = int.replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator); - if (typeof precision === 'number') { - decimal = padEnd(decimal, precision, '0').slice(0, precision); - } + int = int.replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator); + if (typeof precision === 'number') { + decimal = padEnd(decimal, precision, '0').slice(0, precision); + } - if (decimal) { - decimal = `${decimalSeparator}${decimal}`; - } + if (decimal) { + decimal = `${decimalSeparator}${decimal}`; + } - valueNode = [ - - {negative} - {int} - , - decimal && ( - - {decimal} - - ), - ]; + valueNode = [ + + {negative} + {int} + , + decimal && ( + + {decimal} + + ), + ]; + } } - } - - return {valueNode}; -}; -export default Number; + return {valueNode}; + }, +}); +export default StatisticNumber; diff --git a/components/statistic/Statistic.tsx b/components/statistic/Statistic.tsx index e9836bbcb4..bfca2a19d5 100644 --- a/components/statistic/Statistic.tsx +++ b/components/statistic/Statistic.tsx @@ -36,7 +36,9 @@ export default defineComponent({ configProvider: inject('configProvider', defaultConfigProvider), }; }, - + updated() { + (this.$refs.statisticNumber as any).$forceUpdate(); + }, render() { const { prefixCls: customizePrefixCls, value = 0, valueStyle, valueRender } = this.$props; const { getPrefixCls } = this.configProvider; @@ -52,7 +54,7 @@ export default defineComponent({ value, formatter, }; - let valueNode = ; + let valueNode = ; if (valueRender) { valueNode = valueRender(valueNode); } From dc9740260badc67512d1862530365cf1c62430de Mon Sep 17 00:00:00 2001 From: chsword Date: Sat, 14 Nov 2020 03:34:46 +0800 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20=F0=9F=90=9E=20=E5=A2=9E=E5=8A=A0=20?= =?UTF-8?q?inheritAttrs:false=20=E4=BB=A5=E7=AC=A6=E5=90=88=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E7=9A=84=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/statistic/Number.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/components/statistic/Number.tsx b/components/statistic/Number.tsx index de92b30517..afb4f7bfdc 100644 --- a/components/statistic/Number.tsx +++ b/components/statistic/Number.tsx @@ -22,6 +22,7 @@ export const NumberProps = { precision: PropTypes.number, }; const StatisticNumber = defineComponent({ + inheritAttrs: false, props: initDefaultProps(NumberProps, {}), render() { const { From 21f76606d2b5f4d60a6334819272a260cca3428d Mon Sep 17 00:00:00 2001 From: chsword Date: Sat, 14 Nov 2020 10:19:30 +0800 Subject: [PATCH 6/6] =?UTF-8?q?perf:=20=F0=9F=93=88=20Countdown=20update?= =?UTF-8?q?=20=E6=97=B6=20=E4=BB=85forceUpdate=20StatisticNumber=20?= =?UTF-8?q?=E8=80=8C=E4=B8=8D=E6=98=AF=E5=85=A8=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/statistic/Countdown.tsx | 2 +- components/statistic/Statistic.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/components/statistic/Countdown.tsx b/components/statistic/Countdown.tsx index ce4be77aeb..1209b2dbc3 100644 --- a/components/statistic/Countdown.tsx +++ b/components/statistic/Countdown.tsx @@ -47,7 +47,7 @@ export default defineComponent({ startTimer() { if (this.countdownId) return; this.countdownId = window.setInterval(() => { - (this.$refs.statistic as any).$forceUpdate(); + (this.$refs.statistic as any).updateStatisticNumber(); this.syncTimer(); }, REFRESH_INTERVAL); }, diff --git a/components/statistic/Statistic.tsx b/components/statistic/Statistic.tsx index bfca2a19d5..cf671f2b4a 100644 --- a/components/statistic/Statistic.tsx +++ b/components/statistic/Statistic.tsx @@ -36,8 +36,10 @@ export default defineComponent({ configProvider: inject('configProvider', defaultConfigProvider), }; }, - updated() { - (this.$refs.statisticNumber as any).$forceUpdate(); + methods: { + updateStatisticNumber() { + (this.$refs.statisticNumber as any).$forceUpdate(); + }, }, render() { const { prefixCls: customizePrefixCls, value = 0, valueStyle, valueRender } = this.$props;