mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 19:22:44 +08:00
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
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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,
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user