去掉解释性提示和链条上的类型标注
链条回到纯名字。类型标注和「某某组自己决定选中哪一条」那句解释是我上一版加的, 用来说明为什么那一层点不了——但不能点的东西本来就没画出来,解释一个看不见的东西 只是噪音。 默认入站那条压成一句,内核未连接那条压成四个字,没有附加规则时整行不显示而不是 显示一个破折号。shared 里跟着没人用的 autoDecidedHops 一并删掉。
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { describe, expect, it } from 'bun:test'
|
import { describe, expect, it } from 'bun:test'
|
||||||
import { acceptsManualChoice, autoDecidedHops, lastSwitchableGroup, resolveChain } from './outbound-chain.ts'
|
import { acceptsManualChoice, lastSwitchableGroup, resolveChain } from './outbound-chain.ts'
|
||||||
import type { RuntimeNode } from './outbound-chain.ts'
|
import type { RuntimeNode } from './outbound-chain.ts'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,13 +97,3 @@ describe('找出用户能换选中的那一层', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('哪几层是自动决定的', () => {
|
|
||||||
it('列出来,界面用它解释为什么这一层点不了', () => {
|
|
||||||
const chain = resolveChain(runtime, 'PROXY')
|
|
||||||
expect(autoDecidedHops(runtime, chain)).toEqual([{ name: 'AUTO', type: 'URLTest' }])
|
|
||||||
})
|
|
||||||
|
|
||||||
it('线路本身不算——它不是组,本来就没得选', () => {
|
|
||||||
expect(autoDecidedHops(runtime, ['[vless]Gomami'])).toEqual([])
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -79,17 +79,3 @@ export function lastSwitchableGroup(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 链条上那些自动决定选中结果的组。
|
|
||||||
*
|
|
||||||
* 界面用它来解释「为什么这一层点不了」——不说清楚的话,用户看到链条里有个组却没法
|
|
||||||
* 操作,只会以为是坏了。
|
|
||||||
*/
|
|
||||||
export function autoDecidedHops(
|
|
||||||
runtime: Record<string, RuntimeNode>,
|
|
||||||
chain: string[],
|
|
||||||
): Array<{ name: string; type: string }> {
|
|
||||||
return chain
|
|
||||||
.map((name) => ({ name, type: runtime[name]?.type ?? '' }))
|
|
||||||
.filter((hop) => hop.type !== '' && !acceptsManualChoice(hop.type) && runtime[hop.name]?.all)
|
|
||||||
}
|
|
||||||
|
|||||||
+10
-35
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import type { Inbound, OutboundMode } from '@shared/inbounds.ts'
|
import type { Inbound, OutboundMode } from '@shared/inbounds.ts'
|
||||||
import { autoDecidedHops, lastSwitchableGroup, resolveChain } from '@shared/outbound-chain.ts'
|
import { lastSwitchableGroup, resolveChain } from '@shared/outbound-chain.ts'
|
||||||
import { latestDelay } from '../api'
|
import { latestDelay } from '../api'
|
||||||
import { kernel, providerLines, runtime } from '../runtime'
|
import { kernel, providerLines, runtime } from '../runtime'
|
||||||
import OutboundCard from '../components/OutboundCard.vue'
|
import OutboundCard from '../components/OutboundCard.vue'
|
||||||
@@ -50,10 +50,7 @@ const isTesting = (name: string) => props.testing.includes(name)
|
|||||||
|
|
||||||
const chain = computed(() => resolveChain(runtime.value, props.destination))
|
const chain = computed(() => resolveChain(runtime.value, props.destination))
|
||||||
const switchable = computed(() => lastSwitchableGroup(runtime.value, chain.value))
|
const switchable = computed(() => lastSwitchableGroup(runtime.value, chain.value))
|
||||||
/** 链条上那些自己算选中结果的组,用来解释为什么它们点不了。 */
|
|
||||||
const autoHops = computed(() => autoDecidedHops(runtime.value, chain.value))
|
|
||||||
/** 每一跳的类型,显示在链条上。线路显示协议,策略组显示它是怎么选的。 */
|
|
||||||
const hopType = (name: string) => runtime.value[name]?.type ?? ''
|
|
||||||
|
|
||||||
function isCurrentOutbound(mode: OutboundMode): boolean {
|
function isCurrentOutbound(mode: OutboundMode): boolean {
|
||||||
const now = props.inbound.outbound
|
const now = props.inbound.outbound
|
||||||
@@ -89,29 +86,23 @@ const NO_PROXY_FIELD = '该入站没有 proxy 字段'
|
|||||||
<dd class="mono">{{ inbound.type }}</dd>
|
<dd class="mono">{{ inbound.type }}</dd>
|
||||||
<dt>监听</dt>
|
<dt>监听</dt>
|
||||||
<dd class="mono">{{ inbound.listen ?? '0.0.0.0' }}</dd>
|
<dd class="mono">{{ inbound.listen ?? '0.0.0.0' }}</dd>
|
||||||
<dt>附加规则</dt>
|
<template v-if="inbound.ruleSet">
|
||||||
<dd class="mono">{{ inbound.ruleSet ?? '—' }}</dd>
|
<dt>附加规则</dt>
|
||||||
|
<dd class="mono">{{ inbound.ruleSet }}</dd>
|
||||||
|
</template>
|
||||||
</dl>
|
</dl>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<!-- 运行时:换线路。不写文件,点了立刻变 -->
|
<!-- 运行时:换线路。不写文件,点了立刻变 -->
|
||||||
<section v-if="chain.length" class="block">
|
<section v-if="chain.length" class="block">
|
||||||
<h3>流量去向</h3>
|
<h3>流量去向</h3>
|
||||||
<p class="chain">
|
<p class="chain mono">
|
||||||
<template v-for="(hop, i) in chain" :key="hop">
|
<template v-for="(hop, i) in chain" :key="hop">
|
||||||
<span v-if="i" class="arrow">→</span>
|
<span v-if="i" class="arrow">→</span>
|
||||||
<span class="hop">
|
<span :class="i === chain.length - 1 && 'tail'">{{ hop }}</span>
|
||||||
<span :class="['mono', i === chain.length - 1 && 'tail']">{{ hop }}</span>
|
|
||||||
<span v-if="hopType(hop)" class="hop-type">{{ hopType(hop) }}</span>
|
|
||||||
</span>
|
|
||||||
</template>
|
</template>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p v-if="autoHops.length" class="hint">
|
|
||||||
{{ autoHops.map((h) => `${h.name}(${h.type})`).join('、') }}
|
|
||||||
自己决定选中哪一条,不接受手动指定
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<template v-if="switchable">
|
<template v-if="switchable">
|
||||||
<h4>{{ switchable.group }} 的当前选中</h4>
|
<h4>{{ switchable.group }} 的当前选中</h4>
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
@@ -129,15 +120,12 @@ const NO_PROXY_FIELD = '该入站没有 proxy 字段'
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<p v-else-if="chain.length" class="hint">这条链路上没有可手动选择的策略组</p>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- 配置:换这路入站指向谁。要写文件、要校验 -->
|
<!-- 配置:换这路入站指向谁。要写文件、要校验 -->
|
||||||
<section class="block">
|
<section class="block">
|
||||||
<h3>出站</h3>
|
<h3>出站</h3>
|
||||||
<p v-if="locked" class="hint">
|
<p v-if="locked" class="hint"><code>{{ inbound.legacyKey }}</code> 没有 proxy 字段</p>
|
||||||
由 <code>{{ inbound.legacyKey }}</code> 声明。该写法没有 proxy 字段,出站固定为 RULE。
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div v-if="!locked" class="grid">
|
<div v-if="!locked" class="grid">
|
||||||
<OutboundCard
|
<OutboundCard
|
||||||
@@ -193,10 +181,7 @@ const NO_PROXY_FIELD = '该入站没有 proxy 字段'
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<h4 :class="locked && 'is-dim'">订阅线路</h4>
|
<h4 :class="locked && 'is-dim'">订阅线路</h4>
|
||||||
<p v-if="!kernel.online" class="hint">
|
<p v-if="!kernel.online" class="hint"><IconOffline /> 内核未连接</p>
|
||||||
<IconOffline />
|
|
||||||
内核未连接,无法获取订阅线路
|
|
||||||
</p>
|
|
||||||
<p v-else-if="providerLines.length === 0" class="hint">订阅中没有线路</p>
|
<p v-else-if="providerLines.length === 0" class="hint">订阅中没有线路</p>
|
||||||
<div v-else class="grid">
|
<div v-else class="grid">
|
||||||
<OutboundCard
|
<OutboundCard
|
||||||
@@ -333,16 +318,6 @@ h4 {
|
|||||||
color: var(--c-text-faint);
|
color: var(--c-text-faint);
|
||||||
}
|
}
|
||||||
|
|
||||||
.hop {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: baseline;
|
|
||||||
gap: var(--s-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.hop-type {
|
|
||||||
font-size: var(--t-xs);
|
|
||||||
color: var(--c-text-faint);
|
|
||||||
}
|
|
||||||
|
|
||||||
.chain .tail {
|
.chain .tail {
|
||||||
color: var(--c-accent-text);
|
color: var(--c-accent-text);
|
||||||
|
|||||||
Reference in New Issue
Block a user