mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 11:02:08 +08:00
feat(proxy): support dragging to swap proxy group header sections
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { DragDropProvider } from '@dnd-kit/react'
|
||||
import { defaultRangeExtractor, useVirtualizer } from '@tanstack/react-virtual'
|
||||
import { useLockFn } from 'ahooks'
|
||||
import { throttle } from 'lodash-es'
|
||||
@@ -41,6 +42,10 @@ import {
|
||||
ProxyGroupNavigator,
|
||||
} from './proxy-group-navigator'
|
||||
import { ProxyRender } from './proxy-render'
|
||||
import {
|
||||
PROXY_GROUP_HEADER_SENSORS,
|
||||
useProxyGroupHeaderLayout,
|
||||
} from './use-proxy-group-header-layout'
|
||||
import {
|
||||
hasRenderableItems,
|
||||
type IRenderItem,
|
||||
@@ -365,6 +370,7 @@ function NormalProxyGroups(props: { mode: string }) {
|
||||
saveScrollPosition,
|
||||
} = useProxyRenderState(mode, false, null)
|
||||
const emptyList = useEmptyRenderList()
|
||||
const { onDragEnd: onHeaderDragEnd } = useProxyGroupHeaderLayout()
|
||||
const renderFirstRef = useRef(true)
|
||||
// Do not persist intermediate positions produced while restoring virtual scroll.
|
||||
const isRestoringRef = useRef(false)
|
||||
@@ -574,16 +580,21 @@ function NormalProxyGroups(props: { mode: string }) {
|
||||
|
||||
return (
|
||||
<div style={{ position: 'relative', height: '100%' }}>
|
||||
<StickyVirtualList
|
||||
ref={stickyListRef}
|
||||
items={renderList}
|
||||
isGroupItem={(item) => item.type === 0}
|
||||
getItemKey={(item) => item.key}
|
||||
estimateGroupItemHeight={76}
|
||||
estimateItemHeight={64}
|
||||
renderGroupItem={renderGroupItem}
|
||||
renderItem={renderProxyItem}
|
||||
/>
|
||||
<DragDropProvider
|
||||
sensors={PROXY_GROUP_HEADER_SENSORS}
|
||||
onDragEnd={onHeaderDragEnd}
|
||||
>
|
||||
<StickyVirtualList
|
||||
ref={stickyListRef}
|
||||
items={renderList}
|
||||
isGroupItem={(item) => item.type === 0}
|
||||
getItemKey={(item) => item.key}
|
||||
estimateGroupItemHeight={76}
|
||||
estimateItemHeight={64}
|
||||
renderGroupItem={renderGroupItem}
|
||||
renderItem={renderProxyItem}
|
||||
/>
|
||||
</DragDropProvider>
|
||||
|
||||
{mode === 'rule' && (
|
||||
<ProxyGroupNavigator
|
||||
|
||||
Reference in New Issue
Block a user