feat(proxy): support dragging to swap proxy group header sections

This commit is contained in:
wonfen
2026-09-10 21:39:46 +08:00
parent bf6f43f15b
commit ed0e1b38f0
10 changed files with 343 additions and 144 deletions
+25 -14
View File
@@ -1,3 +1,4 @@
import { DragDropProvider } from '@dnd-kit/react'
import { ExpandMoreRounded } from '@mui/icons-material'
import {
Alert,
@@ -35,6 +36,10 @@ import { ProxyChain } from './proxy-chain'
import { type ProxyChainItem, rebindProxyChainItems } from './proxy-chain-model'
import { ProxyRender } from './proxy-render'
import type { HeadState } from './use-head-state'
import {
PROXY_GROUP_HEADER_SENSORS,
useProxyGroupHeaderLayout,
} from './use-proxy-group-header-layout'
import type { IRenderItem } from './use-render-list'
// ---- Types ----
@@ -315,6 +320,7 @@ export function ProxyGroupsChain(props: ProxyGroupsChainProps) {
onScrollToTop,
} = props
const { proxyView } = useProxiesData()
const { onDragEnd: onHeaderDragEnd } = useProxyGroupHeaderLayout()
// Chain-specific state
const [proxyChain, setProxyChain] = useState<ProxyChainItem[]>(() => {
@@ -455,20 +461,25 @@ export function ProxyGroupsChain(props: ProxyGroupsChainProps) {
// Render virtual list for chain mode
const renderProxyList = (height: string) => (
<ProxyVirtualList
parentRef={parentRef}
height={height}
totalSize={totalSize}
virtualItems={virtualItems}
renderList={renderList}
activeStickyIndex={activeStickyIndex}
isChainMode
measureElement={measureElement}
onLocation={onLocation}
onCheckAll={onCheckAll}
onHeadState={onHeadState}
onChangeProxy={handleChangeProxy}
/>
<DragDropProvider
sensors={PROXY_GROUP_HEADER_SENSORS}
onDragEnd={onHeaderDragEnd}
>
<ProxyVirtualList
parentRef={parentRef}
height={height}
totalSize={totalSize}
virtualItems={virtualItems}
renderList={renderList}
activeStickyIndex={activeStickyIndex}
isChainMode
measureElement={measureElement}
onLocation={onLocation}
onCheckAll={onCheckAll}
onHeadState={onHeadState}
onChangeProxy={handleChangeProxy}
/>
</DragDropProvider>
)
const showRuleHeader = mode === 'rule' && availableGroups.length > 0