上半部分收敛成一条规则:草稿和已保存一致时显示内核现状;不一致时显示 按草稿保存后的样子,将移除的画删除线、新增的虚线描边,即将被移除的当前 选中用危险色警示。点击语义只看卡片:现在就存在的成员点了立刻生效,保存 后才加入的点了是预选,保存成功后再作为运行时动作选上。预览的集合运算在 web/member-preview.ts,组件里只留接线。 其余:订阅选择器重写成可搜索多选(原平铺标签订阅一多就是一面墙);删除 入站换成页面内确认对话框;列表右列解析到最终出口并标注链式;「高级配置」 更名「配置」;表单重置改按内容比较(按引用的话任何一次运行时刷新都会冲掉 未保存的草稿,watch 传返回数组的 getter 同样触发这个问题);保存后先刷 运行时再换配置数据,避免卡片区闪空。
144 lines
3.6 KiB
Vue
144 lines
3.6 KiB
Vue
<script setup lang="ts">
|
|
/**
|
|
* 入站列表。每行一路入站:端口、类型、名字、它落在哪个出站上。
|
|
*
|
|
* 只管显示和选中,不碰任何数据。
|
|
*/
|
|
import { inboundTypeLabel, isUnsetOutbound, outboundLabel } from '@shared/inbounds.ts'
|
|
import { displayName, isGenerated } from '@shared/inbound-groups.ts'
|
|
import { resolveChain } from '@shared/outbound-chain.ts'
|
|
import type { Inbound } from '@shared/inbounds.ts'
|
|
import { isChainedLine, runtime } from '../runtime'
|
|
import IconLink from '~icons/ri/links-line'
|
|
|
|
defineProps<{ inbounds: Inbound[] }>()
|
|
const selected = defineModel<string | null>('selected', { required: true })
|
|
|
|
/**
|
|
* 这一行右侧显示什么。
|
|
*
|
|
* 指向 Patchbay 自动创建的代理组时,顺着「当前选中」解析到最终出口——组名和左边的
|
|
* 名字列完全重复,而组选中 AUTO 时「AUTO」也不是答案,用户要的是流量走哪条线。
|
|
* 出口经过链式代理入口时带一个标记,和详情里的流量去向对得上。
|
|
*/
|
|
function outboundOf(inbound: Inbound): { text: string; chained: boolean } {
|
|
const mode = inbound.outbound
|
|
if (mode.kind !== 'named' || !isGenerated(mode.name))
|
|
return { text: outboundLabel(mode), chained: false }
|
|
const exit = resolveChain(runtime.value, runtime.value[mode.name]?.now ?? null).at(-1)
|
|
return {
|
|
text: displayName(exit ?? '') || '未选择',
|
|
chained: exit !== undefined && isChainedLine(exit),
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<ol class="rows">
|
|
<li v-for="inbound in inbounds" :key="inbound.id">
|
|
<button
|
|
type="button"
|
|
:class="['line', selected === inbound.id && 'is-on']"
|
|
@click="selected = inbound.id"
|
|
>
|
|
<span class="port mono">{{ inbound.port }}</span>
|
|
<span class="type mono">{{ inboundTypeLabel(inbound.type) }}</span>
|
|
<span class="name">
|
|
{{ inbound.name }}
|
|
<span v-if="inbound.isDefault" class="tag">默认</span>
|
|
</span>
|
|
<span :class="['out mono', isUnsetOutbound(inbound.outbound) && 'is-muted']">
|
|
<span v-if="outboundOf(inbound).chained" class="chain" title="经过链式代理">
|
|
<IconLink />
|
|
</span>
|
|
{{ outboundOf(inbound).text }}
|
|
</span>
|
|
</button>
|
|
</li>
|
|
</ol>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.rows {
|
|
list-style: none;
|
|
margin: 0;
|
|
padding: 0;
|
|
border: 1px solid var(--c-border);
|
|
border-radius: var(--r-md);
|
|
background: var(--c-surface);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.rows li + li {
|
|
border-top: 1px solid var(--c-border);
|
|
}
|
|
|
|
.line {
|
|
width: 100%;
|
|
display: grid;
|
|
grid-template-columns: 4.5rem 5rem 1fr minmax(5rem, auto);
|
|
align-items: center;
|
|
gap: var(--s-3);
|
|
padding: var(--s-3) var(--s-4);
|
|
border: none;
|
|
background: none;
|
|
cursor: pointer;
|
|
text-align: left;
|
|
}
|
|
|
|
.line:hover {
|
|
background: var(--c-surface-sunken);
|
|
}
|
|
|
|
.line.is-on {
|
|
background: var(--c-accent-soft);
|
|
}
|
|
|
|
.port {
|
|
font-size: var(--t-lg);
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
|
|
.type {
|
|
font-size: var(--t-xs);
|
|
color: var(--c-text-faint);
|
|
}
|
|
|
|
.name {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: var(--s-2);
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.tag {
|
|
flex: none;
|
|
padding: 0 var(--s-2);
|
|
border: 1px solid var(--c-border-strong);
|
|
border-radius: 999px;
|
|
font-size: var(--t-xs);
|
|
color: var(--c-text-soft);
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.out {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: flex-end;
|
|
gap: var(--s-1);
|
|
font-size: var(--t-sm);
|
|
}
|
|
|
|
.chain {
|
|
display: flex;
|
|
color: var(--c-chain-text);
|
|
}
|
|
|
|
.out.is-muted {
|
|
color: var(--c-text-faint);
|
|
}
|
|
</style>
|