From 5043b8706d3d1084d5d75b6f422e18acfd406df0 Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Thu, 19 Nov 2026 23:16:44 +0800 Subject: [PATCH] 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. --- src/components/home/test-card.tsx | 4 +++- .../profile/grouped-virtual-list.tsx | 4 +++- src/components/proxy/proxy-chain.tsx | 7 +++---- src/services/notice-service.ts | 18 +++++++++++++++--- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/components/home/test-card.tsx b/src/components/home/test-card.tsx index 77e854357..310c1f24c 100644 --- a/src/components/home/test-card.tsx +++ b/src/components/home/test-card.tsx @@ -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 = () => { } > - + {renderTestItems} diff --git a/src/components/profile/grouped-virtual-list.tsx b/src/components/profile/grouped-virtual-list.tsx index 07b657f37..f705d443c 100644 --- a/src/components/profile/grouped-virtual-list.tsx +++ b/src/components/profile/grouped-virtual-list.tsx @@ -56,6 +56,8 @@ interface GroupedVirtualListProps { style?: CSSProperties } +const GROUPED_LIST_SENSORS = [PointerSensor, KeyboardSensor] + /** * 用于编辑规则/节点/代理组功能的 prepend/original/append 分组虚拟化列表 */ @@ -141,7 +143,7 @@ export function GroupedVirtualList(props: GroupedVirtualListProps) { return ( undefined, }) +const CHAIN_SENSORS = [chainPointerSensor, KeyboardSensor] + type RuntimeConfigWithProxySequence = IConfigData & { proxies?: unknown } interface ProxyChainProps { @@ -665,10 +667,7 @@ export const ProxyChain = ({ ) : ( - + {currentProxyChain.map((proxy, index) => ( 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) {