mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 06:19:05 +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": "^3.5.3",
|
||||||
"prettier-plugin-sort-json": "^4.1.1",
|
"prettier-plugin-sort-json": "^4.1.1",
|
||||||
"proxy-agent": "^6.5.0",
|
"proxy-agent": "^6.5.0",
|
||||||
"rc-virtual-list": "^3.18.6",
|
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.0.0",
|
||||||
"react-hotkeys-hook": "^4.6.1",
|
"react-hotkeys-hook": "^4.6.1",
|
||||||
|
|||||||
@ -29,14 +29,14 @@ vi.mock('@hello-pangea/dnd', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// mock VirtualList 只做简单渲染
|
// mock antd list 只做简单渲染
|
||||||
vi.mock('rc-virtual-list', () => ({
|
vi.mock('antd', () => ({
|
||||||
__esModule: true,
|
__esModule: true,
|
||||||
default: ({ data, itemKey, children }: any) => (
|
List: ({ dataSource, renderItem }: any) => (
|
||||||
<div data-testid="virtual-list">
|
<div data-testid="virtual-list">
|
||||||
{data.map((item: any, idx: number) => (
|
{dataSource.map((item: any, idx: number) => (
|
||||||
<div key={item[itemKey] || item} data-testid="virtual-list-item">
|
<div key={item.id || item} data-testid="virtual-list-item">
|
||||||
{children(item, idx)}
|
{renderItem(item, idx)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
/// <reference types="@vitest/browser/context" />
|
|
||||||
|
|
||||||
import { render, screen } from '@testing-library/react'
|
import { render, screen } from '@testing-library/react'
|
||||||
import { describe, expect, it, vi } from 'vitest'
|
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', () => ({
|
vi.mock('@renderer/components/Scrollbar', () => ({
|
||||||
__esModule: true,
|
__esModule: true,
|
||||||
default: ({ ref, children, ...props }) => (
|
default: ({ ref, children, ...props }) => (
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import {
|
|||||||
ResponderProvided
|
ResponderProvided
|
||||||
} from '@hello-pangea/dnd'
|
} from '@hello-pangea/dnd'
|
||||||
import { droppableReorder } from '@renderer/utils'
|
import { droppableReorder } from '@renderer/utils'
|
||||||
import VirtualList from 'rc-virtual-list'
|
import { List } from 'antd'
|
||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
|
|
||||||
interface Props<T> {
|
interface Props<T> {
|
||||||
@ -50,8 +50,9 @@ const DraggableList: FC<Props<any>> = ({
|
|||||||
<Droppable droppableId="droppable" {...droppableProps}>
|
<Droppable droppableId="droppable" {...droppableProps}>
|
||||||
{(provided) => (
|
{(provided) => (
|
||||||
<div {...provided.droppableProps} ref={provided.innerRef} style={style}>
|
<div {...provided.droppableProps} ref={provided.innerRef} style={style}>
|
||||||
<VirtualList data={list} itemKey="id">
|
<List
|
||||||
{(item, index) => {
|
dataSource={list}
|
||||||
|
renderItem={(item, index) => {
|
||||||
const id = item.id || item
|
const id = item.id || item
|
||||||
return (
|
return (
|
||||||
<Draggable key={`draggable_${id}_${index}`} draggableId={id} index={index}>
|
<Draggable key={`draggable_${id}_${index}`} draggableId={id} index={index}>
|
||||||
@ -71,7 +72,7 @@ const DraggableList: FC<Props<any>> = ({
|
|||||||
</Draggable>
|
</Draggable>
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
</VirtualList>
|
/>
|
||||||
{provided.placeholder}
|
{provided.placeholder}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -8603,7 +8603,6 @@ __metadata:
|
|||||||
prettier: "npm:^3.5.3"
|
prettier: "npm:^3.5.3"
|
||||||
prettier-plugin-sort-json: "npm:^4.1.1"
|
prettier-plugin-sort-json: "npm:^4.1.1"
|
||||||
proxy-agent: "npm:^6.5.0"
|
proxy-agent: "npm:^6.5.0"
|
||||||
rc-virtual-list: "npm:^3.18.6"
|
|
||||||
react: "npm:^19.0.0"
|
react: "npm:^19.0.0"
|
||||||
react-dom: "npm:^19.0.0"
|
react-dom: "npm:^19.0.0"
|
||||||
react-hotkeys-hook: "npm:^4.6.1"
|
react-hotkeys-hook: "npm:^4.6.1"
|
||||||
@ -19042,7 +19041,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
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
|
version: 3.18.6
|
||||||
resolution: "rc-virtual-list@npm:3.18.6"
|
resolution: "rc-virtual-list@npm:3.18.6"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user