Files
clash-verge-rev/src/components/proxy/proxy-chain-model.ts
T
wonfen 304f5bade9 perf(proxy): consolidate proxy data into a single IPC (#7542)
* feat(proxy): build deterministic proxy view

* feat(proxy): expose ordered proxy view command

* feat(proxy): add proxy view client contract

* fix(lint): allow Node test files

* feat(proxy): switch UI to ordered proxy view

* fix(proxy): harden ordered proxy view consumers

* fix(proxy): compare chain duplicates by current id

* fix(proxy): release mihomo guard after fetch

* fix(proxy): preserve semantic selections across refresh

* fix(proxy): block global chain without GLOBAL

* fix(proxy): handle proxy view edge states
2026-07-21 00:11:59 +08:00

37 lines
854 B
TypeScript

import {
getRecord,
rebindNode,
type ProxyNodeView,
type ProxyViewV1,
} from '@/types/proxy-view'
export interface ProxyChainItem {
id: string
name: string
recordId?: string
source?: ProxyNodeView['source']
type?: string
delay?: number
}
export const rebindProxyChainItems = (
items: readonly ProxyChainItem[],
candidates: readonly ProxyNodeView[],
proxyView: ProxyViewV1,
): ProxyChainItem[] =>
items.map((item) => {
const rebound = rebindNode(candidates, {
name: item.name,
source: item.source,
})
const record =
rebound === undefined ? undefined : getRecord(proxyView, rebound.recordId)
return {
...item,
recordId: rebound?.recordId,
source: rebound?.source ?? item.source,
type: rebound?.type ?? item.type,
delay: record?.history.at(-1)?.delay,
}
})