mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-25 11:20:07 +08:00
refactor: remove rc-virtual-list from DraggableList (#9258)
This commit is contained in:
parent
0b8c6ee536
commit
afae33d588
@ -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",
|
||||
|
||||
@ -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) => (
|
||||
<div data-testid="virtual-list">
|
||||
{data.map((item: any, idx: number) => (
|
||||
<div key={item[itemKey] || item} data-testid="virtual-list-item">
|
||||
{children(item, idx)}
|
||||
{dataSource.map((item: any, idx: number) => (
|
||||
<div key={item.id || item} data-testid="virtual-list-item">
|
||||
{renderItem(item, idx)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
/// <reference types="@vitest/browser/context" />
|
||||
|
||||
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 }) => <div data-testid="auto-sizer">{children({ height: 500, width: 300 })}</div>
|
||||
}))
|
||||
|
||||
vi.mock('@renderer/components/Scrollbar', () => ({
|
||||
__esModule: true,
|
||||
default: ({ ref, children, ...props }) => (
|
||||
|
||||
@ -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<T> {
|
||||
@ -50,8 +50,9 @@ const DraggableList: FC<Props<any>> = ({
|
||||
<Droppable droppableId="droppable" {...droppableProps}>
|
||||
{(provided) => (
|
||||
<div {...provided.droppableProps} ref={provided.innerRef} style={style}>
|
||||
<VirtualList data={list} itemKey="id">
|
||||
{(item, index) => {
|
||||
<List
|
||||
dataSource={list}
|
||||
renderItem={(item, index) => {
|
||||
const id = item.id || item
|
||||
return (
|
||||
<Draggable key={`draggable_${id}_${index}`} draggableId={id} index={index}>
|
||||
@ -71,7 +72,7 @@ const DraggableList: FC<Props<any>> = ({
|
||||
</Draggable>
|
||||
)
|
||||
}}
|
||||
</VirtualList>
|
||||
/>
|
||||
{provided.placeholder}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user