每路入站配一组专属策略组,换线不再改配置文件

原本换一条线要改 config.yaml、跑校验、等内核重载,几秒起步;而换线恰恰是这个工具
最高频的动作,把它放在最重的路径上方向就错了。现在每一路配一个 select 组加 AUTO、
FALLBACK 两个,入站的 proxy 永久指向 select,换线只是调一次内核接口。这样做的前提是
选中不会丢:内核把它写进 cache 文件,重启后由 patchSelectGroup 恢复,而
profile.store-selected 默认为真。

链式代理靠给来源订阅复制一份声明、挂上 override.dialer-proxy 实现,因为这个字段写在
策略组上内核只会打条日志然后忽略。副本是 type: file 读原订阅已经落盘的缓存,而不是
自己再拉一次:自己拉的话订阅地址一不可达副本就是空的,那一路入站会一条线都不剩,
表现是端口还在监听却没有任何出口。

顺带把 shared/outbound-chain.ts 里「只有 Selector 接受手动选择」那条断言删了,它是
错的(内核检查的是 SelectAble 接口,URLTest 和 Fallback 也实现了)。界面仍然只让
Selector 可点,但理由换成了另外两种的手动指定会被它们自己撤销。

完整取舍见工作区决策记录 0007。
This commit is contained in:
2026-08-11 03:10:38 +08:00
parent afe53b9790
commit e9e2eb555d
19 changed files with 1807 additions and 567 deletions
+15 -2
View File
@@ -5,11 +5,24 @@
* 只管显示和选中,不碰任何数据。
*/
import { inboundTypeLabel, isUnsetOutbound, outboundLabel } from '@shared/inbounds.ts'
import { displayOutboundName } from '@shared/filter-groups.ts'
import { displayName, isGenerated } from '@shared/inbound-groups.ts'
import type { Inbound } from '@shared/inbounds.ts'
import { runtime } from '../runtime'
defineProps<{ inbounds: Inbound[] }>()
const selected = defineModel<string | null>('selected', { required: true })
/**
* 这一行右侧显示什么。
*
* 指向 Patchbay 自动创建的代理组时显示那个组当前选中的线路,而不是组名——组名是
* 「patchbay:」加入站名,和左边的名字列完全重复,等于一列没有信息。
*/
function outboundOf(inbound: Inbound): string {
const mode = inbound.outbound
if (mode.kind !== 'named' || !isGenerated(mode.name)) return outboundLabel(mode)
return displayName(runtime.value[mode.name]?.now ?? '') || '未选择'
}
</script>
<template>
@@ -27,7 +40,7 @@ const selected = defineModel<string | null>('selected', { required: true })
<span v-if="inbound.isDefault" class="tag">默认</span>
</span>
<span :class="['out mono', isUnsetOutbound(inbound.outbound) && 'is-muted']">
{{ displayOutboundName(outboundLabel(inbound.outbound)) }}
{{ outboundOf(inbound) }}
</span>
</button>
</li>