diff --git a/src/CollapseCard/index.tsx b/src/CollapseCard/index.tsx index 681567ac..cdf8808d 100644 --- a/src/CollapseCard/index.tsx +++ b/src/CollapseCard/index.tsx @@ -2,7 +2,7 @@ import { useControllableValue } from 'ahooks'; import type { CollapseProps } from 'antd'; import { Collapse } from 'antd'; import classnames from 'classnames'; -import { emptyObject } from 'lighting-design/constants'; +import { emptyArray, emptyObject } from 'lighting-design/constants'; import { useMemo, type CSSProperties, type FC, type ReactNode } from 'react'; import './index.less'; @@ -204,7 +204,7 @@ const LCollapseCard: FC = (props) => { = memo((props) => { const { @@ -64,11 +52,7 @@ const LECharts: FC = memo((props) => { /** echarts.init 初始化实例 */ const initEchartsInstance = useMemoizedFn(async () => { return new Promise((resolve) => { - const echartsInstance = (echartsInstanceRef.current = echarts.init( - ref.current, - theme, - opts, - )); + const echartsInstance = (echartsInstanceRef.current = echarts.init(ref.current, theme, opts)); resolve(echartsInstance); }); }); @@ -83,7 +67,7 @@ const LECharts: FC = memo((props) => { ) { echartOption = transformEchartsOption( fastDeepClone(option), // 必须先深克隆 - [...new Set(['fontSize', ...(autoResizeFields || [])])], + [...new Set(['fontSize', ...(autoResizeFields || emptyArray)])], designWidth, ); } else { @@ -98,14 +82,8 @@ const LECharts: FC = memo((props) => { /** 绑定图表实例事件 */ const bindEvents = useMemoizedFn( - ( - instance: ECharts, - events: Record void>, - ) => { - function _bindEvent( - eventName: string, - func: (params: any, ins: ECharts) => void, - ) { + (instance: ECharts, events: Record void>) => { + function _bindEvent(eventName: string, func: (params: any, ins: ECharts) => void) { if (isString(eventName) && isFunction(func)) { instance.on(eventName, (param: any) => { func(param, instance); @@ -208,10 +186,7 @@ const LECharts: FC = memo((props) => { } // 如果 style 或者 className 变化 重新resize - if ( - !isEqual(prevProps?.style, style) || - !isEqual(prevProps?.className, className) - ) { + if (!isEqual(prevProps?.style, style) || !isEqual(prevProps?.className, className)) { resize(); } }, [ @@ -247,9 +222,7 @@ const LECharts: FC = memo((props) => { }; }); - return ( -
- ); + return
; }); // 第一步优化性能 diff --git a/src/TreeTable/index.tsx b/src/TreeTable/index.tsx index f36d3e79..bae24b16 100644 --- a/src/TreeTable/index.tsx +++ b/src/TreeTable/index.tsx @@ -147,11 +147,11 @@ const LTreeTable: React.FC = (props) => { } = props; const [checkList, setCheckList] = useControllableValue({ - defaultValue: defaultValue || [], + defaultValue: defaultValue || emptyArray, ...props, }); - const [indeterminateList, setIndeterminateList] = useRafState([]); + const [indeterminateList, setIndeterminateList] = useRafState(emptyArray); const fieldNames = useCreation( () => ({ @@ -187,8 +187,8 @@ const LTreeTable: React.FC = (props) => { // 处理当前值的父级选中与半选中 const processParentChecked = useMemoizedFn( (currentValue?: ValueType, checks?: ValueType[], indetermanites?: ValueType[]) => { - const newChecks = new Set(checks || []); - const newIndetermanites = new Set(indetermanites || []); + const newChecks = new Set(checks || emptyArray); + const newIndetermanites = new Set(indetermanites || emptyArray); // 递归处理父级勾选 function recursion(parentVal: ValueType) { @@ -264,7 +264,7 @@ const LTreeTable: React.FC = (props) => { const handleChange = useMemoizedFn((subItem: LTreeTableDataItem) => { const newCheckList = new Set(checkList || []); - const newIndetermaniteList = new Set(indeterminateList || []); + const newIndetermaniteList = new Set(indeterminateList || emptyArray); const currentValue = subItem[valueKey]; const currentChecked = newCheckList.has(currentValue); @@ -278,7 +278,7 @@ const LTreeTable: React.FC = (props) => { if (checkStrictly) { setCheckList([...newCheckList]); - setIndeterminateList([]); + setIndeterminateList(emptyArray); return; } @@ -337,7 +337,7 @@ const LTreeTable: React.FC = (props) => { ? innerColumns : outColumns?.length ? outColumns.map((item) => item) - : []; + : emptyArray; return internalColumns.map((item, i) => ({ ...item, @@ -345,7 +345,7 @@ const LTreeTable: React.FC = (props) => { ...outColumns?.[i], onCell: (record: Record, rowIndex: number) => { const col = record[item.dataIndex]; - const outOnCell = outColumns?.[i]?.onCell?.(record, rowIndex) ?? {}; + const outOnCell = outColumns?.[i]?.onCell?.(record, rowIndex) ?? emptyObject; return { ...outOnCell, rowSpan: col.rowSpan, @@ -386,7 +386,7 @@ const LTreeTable: React.FC = (props) => { {...restProps} {...tableProps} className={classnames(prefixCls, className, tableProps?.className)} - dataSource={realDataSource ?? []} + dataSource={realDataSource ?? emptyArray} columns={realColumns} /> );