mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-20 02:42:12 +08:00
perf(ui): batch notice removal and hoist drag sensors
hideNoticesByCode removed matching notices one by one, notifying subscribers per item; it now filters in one pass and notifies once. The chain list, test card and grouped editor list allocated their drag sensor arrays per render; they are module constants now.
This commit is contained in:
@@ -23,6 +23,8 @@ import { emitTestAll } from '@/services/bus'
|
||||
|
||||
import { EnhancedCard } from './enhanced-card'
|
||||
|
||||
const TEST_LIST_SENSORS = [PointerSensor]
|
||||
|
||||
// 自定义滚动条样式
|
||||
const ScrollBox = styled(Box)(({ theme }) => ({
|
||||
maxHeight: '180px',
|
||||
@@ -205,7 +207,7 @@ export const TestCard = () => {
|
||||
}
|
||||
>
|
||||
<ScrollBox>
|
||||
<DragDropProvider sensors={[PointerSensor]} onDragEnd={onDragEnd}>
|
||||
<DragDropProvider sensors={TEST_LIST_SENSORS} onDragEnd={onDragEnd}>
|
||||
{renderTestItems}
|
||||
</DragDropProvider>
|
||||
</ScrollBox>
|
||||
|
||||
@@ -56,6 +56,8 @@ interface GroupedVirtualListProps<T> {
|
||||
style?: CSSProperties
|
||||
}
|
||||
|
||||
const GROUPED_LIST_SENSORS = [PointerSensor, KeyboardSensor]
|
||||
|
||||
/**
|
||||
* 用于编辑规则/节点/代理组功能的 prepend/original/append 分组虚拟化列表
|
||||
*/
|
||||
@@ -141,7 +143,7 @@ export function GroupedVirtualList<T>(props: GroupedVirtualListProps<T>) {
|
||||
|
||||
return (
|
||||
<DragDropProvider
|
||||
sensors={[PointerSensor, KeyboardSensor]}
|
||||
sensors={GROUPED_LIST_SENSORS}
|
||||
onDragStart={onDragStart}
|
||||
onDragOver={onDragOver}
|
||||
onDragEnd={onDragEnd}
|
||||
|
||||
@@ -57,6 +57,8 @@ const chainPointerSensor = PointerSensor.configure({
|
||||
activationConstraints: () => undefined,
|
||||
})
|
||||
|
||||
const CHAIN_SENSORS = [chainPointerSensor, KeyboardSensor]
|
||||
|
||||
type RuntimeConfigWithProxySequence = IConfigData & { proxies?: unknown }
|
||||
|
||||
interface ProxyChainProps {
|
||||
@@ -665,10 +667,7 @@ export const ProxyChain = ({
|
||||
</Button>
|
||||
</Box>
|
||||
) : (
|
||||
<DragDropProvider
|
||||
sensors={[chainPointerSensor, KeyboardSensor]}
|
||||
onDragEnd={handleDragEnd}
|
||||
>
|
||||
<DragDropProvider sensors={CHAIN_SENSORS} onDragEnd={handleDragEnd}>
|
||||
<Box sx={{ borderRadius: 1, minHeight: 60, p: 1 }}>
|
||||
{currentProxyChain.map((proxy, index) => (
|
||||
<SortableProxyChainItem
|
||||
|
||||
@@ -514,9 +514,21 @@ export function hideNotice(id: number) {
|
||||
}
|
||||
|
||||
function hideNoticesByCode(code: string) {
|
||||
notices
|
||||
.filter((notice) => notice.code === code)
|
||||
.forEach(({ id }) => hideNotice(id))
|
||||
// One subscriber notification for the whole batch; per-notice removal
|
||||
// would notify once per item.
|
||||
const remaining: NoticeItem[] = []
|
||||
let removed = false
|
||||
for (const notice of notices) {
|
||||
if (notice.code === code) {
|
||||
removed = true
|
||||
if (notice.timerId) clearTimeout(notice.timerId)
|
||||
} else {
|
||||
remaining.push(notice)
|
||||
}
|
||||
}
|
||||
if (!removed) return
|
||||
notices = remaining
|
||||
notifySubscribers()
|
||||
}
|
||||
|
||||
export function syncSidecarFailure(snapshot: SidecarFailureSnapshot) {
|
||||
|
||||
Reference in New Issue
Block a user