From 3bacb9e75c51d32dfa1c387928ed1b4809397732 Mon Sep 17 00:00:00 2001 From: Electrolux <3451613934@qq.com> Date: Fri, 22 Mar 2024 14:51:27 +0800 Subject: [PATCH] chore(perf): perf the format --- components/vc-table/Cell/index.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/components/vc-table/Cell/index.tsx b/components/vc-table/Cell/index.tsx index a06d0bc472..4e8f45d0fa 100644 --- a/components/vc-table/Cell/index.tsx +++ b/components/vc-table/Cell/index.tsx @@ -104,7 +104,6 @@ export default defineComponent({ 'transformCellText', ] as any, setup(props, { slots }) { - const hoverRef = ref(null) const contextSlots = useInjectSlots(); const { onHover, startRow, endRow } = useInjectHover(); @@ -122,6 +121,10 @@ export default defineComponent({ (props.additionalProps?.rowspan as number) ); }); + const hovering = eagerComputed(() => { + const { index } = props; + return inHoverRange(index, rowSpan.value || 1, startRow.value, endRow.value); + }); const supportSticky = useInjectSticky(); // ====================== Hover ======================= @@ -201,6 +204,7 @@ export default defineComponent({ renderIndex, column: column.__originColumn__, }); + if (isRenderCell(renderData)) { if (process.env.NODE_ENV !== 'production') { warning( @@ -214,6 +218,7 @@ export default defineComponent({ childNode = renderData; } } + if ( !(INTERNAL_COL_DEFINE in column) && cellType === 'body' && @@ -274,7 +279,6 @@ export default defineComponent({ } = cellProps || {}; const mergedColSpan = (cellColSpan !== undefined ? cellColSpan : colSpan.value) ?? 1; const mergedRowSpan = (cellRowSpan !== undefined ? cellRowSpan : rowSpan.value) ?? 1; - if (mergedColSpan === 0 || mergedRowSpan === 0) { return null; } @@ -299,6 +303,7 @@ export default defineComponent({ if (align) { alignStyle.textAlign = align; } + // ====================== Render ====================== let title: string; const ellipsisConfig: CellEllipsisType = ellipsis === true ? { showTitle: true } : ellipsis; @@ -311,10 +316,6 @@ export default defineComponent({ } // AddEventListener Hover - const hovering = eagerComputed(() => { - const { index } = props; - return inHoverRange(index, rowSpan.value || 1, startRow.value, endRow.value); - }); watch([rowSpan,startRow,endRow],()=>{ hoverRef.value?.setAttribute("class",classNames( cellPrefixCls, @@ -338,7 +339,7 @@ export default defineComponent({ [`${cellPrefixCls}-fix-sticky`]: (isFixLeft || isFixRight) && isSticky && supportSticky.value, } - + const componentProps = { title, ...restCellProps, @@ -357,6 +358,7 @@ export default defineComponent({ onMouseleave, style: [additionalProps.style, alignStyle, fixedStyle, cellStyle], }; + return ( {appendNode}