From afae33d588e0f53be398e51eef0f5f0919d6f908 Mon Sep 17 00:00:00 2001 From: one Date: Mon, 18 Aug 2025 09:36:15 +0800 Subject: [PATCH] refactor: remove rc-virtual-list from DraggableList (#9258) --- package.json | 1 - .../DraggableList/__tests__/DraggableList.test.tsx | 12 ++++++------ .../__tests__/DraggableVirtualList.test.tsx | 7 ------- src/renderer/src/components/DraggableList/list.tsx | 9 +++++---- yarn.lock | 3 +-- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 6b974bb8a2..17fcc325a6 100644 --- a/package.json +++ b/package.json @@ -225,7 +225,6 @@ "prettier": "^3.5.3", "prettier-plugin-sort-json": "^4.1.1", "proxy-agent": "^6.5.0", - "rc-virtual-list": "^3.18.6", "react": "^19.0.0", "react-dom": "^19.0.0", "react-hotkeys-hook": "^4.6.1", diff --git a/src/renderer/src/components/DraggableList/__tests__/DraggableList.test.tsx b/src/renderer/src/components/DraggableList/__tests__/DraggableList.test.tsx index ed53736ed5..d6c1aa7b21 100644 --- a/src/renderer/src/components/DraggableList/__tests__/DraggableList.test.tsx +++ b/src/renderer/src/components/DraggableList/__tests__/DraggableList.test.tsx @@ -29,14 +29,14 @@ vi.mock('@hello-pangea/dnd', () => { } }) -// mock VirtualList 只做简单渲染 -vi.mock('rc-virtual-list', () => ({ +// mock antd list 只做简单渲染 +vi.mock('antd', () => ({ __esModule: true, - default: ({ data, itemKey, children }: any) => ( + List: ({ dataSource, renderItem }: any) => (
- {data.map((item: any, idx: number) => ( -
- {children(item, idx)} + {dataSource.map((item: any, idx: number) => ( +
+ {renderItem(item, idx)}
))}
diff --git a/src/renderer/src/components/DraggableList/__tests__/DraggableVirtualList.test.tsx b/src/renderer/src/components/DraggableList/__tests__/DraggableVirtualList.test.tsx index 74a7a414ee..523ef89d26 100644 --- a/src/renderer/src/components/DraggableList/__tests__/DraggableVirtualList.test.tsx +++ b/src/renderer/src/components/DraggableList/__tests__/DraggableVirtualList.test.tsx @@ -1,5 +1,3 @@ -/// - import { render, screen } from '@testing-library/react' import { describe, expect, it, vi } from 'vitest' @@ -47,11 +45,6 @@ vi.mock('@tanstack/react-virtual', () => ({ }) })) -vi.mock('react-virtualized-auto-sizer', () => ({ - __esModule: true, - default: ({ children }) =>
{children({ height: 500, width: 300 })}
-})) - vi.mock('@renderer/components/Scrollbar', () => ({ __esModule: true, default: ({ ref, children, ...props }) => ( diff --git a/src/renderer/src/components/DraggableList/list.tsx b/src/renderer/src/components/DraggableList/list.tsx index 18bf7a6d20..3a2cc5b108 100644 --- a/src/renderer/src/components/DraggableList/list.tsx +++ b/src/renderer/src/components/DraggableList/list.tsx @@ -9,7 +9,7 @@ import { ResponderProvided } from '@hello-pangea/dnd' import { droppableReorder } from '@renderer/utils' -import VirtualList from 'rc-virtual-list' +import { List } from 'antd' import { FC } from 'react' interface Props { @@ -50,8 +50,9 @@ const DraggableList: FC> = ({ {(provided) => (
- - {(item, index) => { + { const id = item.id || item return ( @@ -71,7 +72,7 @@ const DraggableList: FC> = ({ ) }} - + /> {provided.placeholder}
)} diff --git a/yarn.lock b/yarn.lock index 1682a91c84..a3d2b15685 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8603,7 +8603,6 @@ __metadata: prettier: "npm:^3.5.3" prettier-plugin-sort-json: "npm:^4.1.1" proxy-agent: "npm:^6.5.0" - rc-virtual-list: "npm:^3.18.6" react: "npm:^19.0.0" react-dom: "npm:^19.0.0" react-hotkeys-hook: "npm:^4.6.1" @@ -19042,7 +19041,7 @@ __metadata: languageName: node linkType: hard -"rc-virtual-list@npm:^3.14.2, rc-virtual-list@npm:^3.18.6, rc-virtual-list@npm:^3.5.1, rc-virtual-list@npm:^3.5.2": +"rc-virtual-list@npm:^3.14.2, rc-virtual-list@npm:^3.5.1, rc-virtual-list@npm:^3.5.2": version: 3.18.6 resolution: "rc-virtual-list@npm:3.18.6" dependencies: