路由页做完:新增、编辑、删除入站
弹窗用原生 <dialog>,焦点捕获和 Esc 关闭是浏览器自带的,自己实现只会更差。 表单字段由那张从内核源码提取的字段表驱动:公共字段加当前类型的必填项。 20 种类型合计 398 个字段,全铺出来没人填得完,冷门的留给配置文件手写。 默认入站不再显示出站选择块——那一整块对它都是不可选的,画出来只是噪音, 换成一行说明。另外去掉了行里那根装饰线,导航把仪表盘挪到路由前面。
This commit is contained in:
@@ -3,8 +3,9 @@ import { computed } from 'vue'
|
||||
import type { Inbound, OutboundMode } from '@shared/inbounds.ts'
|
||||
import { latestDelay } from '../api'
|
||||
import type { ProxyInfo } from '../api'
|
||||
import IconLock from '~icons/ri/lock-line'
|
||||
import IconOffline from '~icons/ri/cloud-off-line'
|
||||
import IconEdit from '~icons/ri/edit-line'
|
||||
import IconDelete from '~icons/ri/delete-bin-line'
|
||||
|
||||
const props = defineProps<{
|
||||
inbound: Inbound
|
||||
@@ -17,7 +18,7 @@ const props = defineProps<{
|
||||
saving: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{ pick: [mode: OutboundMode] }>()
|
||||
const emit = defineEmits<{ pick: [mode: OutboundMode]; edit: []; remove: [] }>()
|
||||
|
||||
interface Option {
|
||||
key: string
|
||||
@@ -111,6 +112,13 @@ function delayClass(ms: number | null): string {
|
||||
<span class="port mono">{{ inbound.port }}</span>
|
||||
<span class="name">{{ inbound.name }}</span>
|
||||
</div>
|
||||
<div v-if="!inbound.isDefault" class="acts">
|
||||
<button type="button" :disabled="saving" @click="emit('edit')"><IconEdit /> 编辑</button>
|
||||
<button type="button" class="danger" :disabled="saving" @click="emit('remove')">
|
||||
<IconDelete /> 删除
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<dl class="facts">
|
||||
<dt>类型</dt>
|
||||
<dd class="mono">{{ inbound.type }}</dd>
|
||||
@@ -121,13 +129,12 @@ function delayClass(ms: number | null): string {
|
||||
</dl>
|
||||
</header>
|
||||
|
||||
<section class="pick">
|
||||
<h3>出站</h3>
|
||||
<p v-if="locked" class="aside-note locked-note">
|
||||
由 <code>{{ inbound.legacyKey }}</code> 声明,这种写法没有 proxy 字段,出站固定是 RULE
|
||||
</p>
|
||||
|
||||
<p v-if="locked" class="aside-note">
|
||||
<IconLock />
|
||||
由 <code>{{ inbound.legacyKey }}</code> 声明,没有 proxy 字段,只能走 RULE
|
||||
</p>
|
||||
<section v-else class="pick">
|
||||
<h3>出站</h3>
|
||||
|
||||
<div class="grid">
|
||||
<button
|
||||
@@ -261,6 +268,43 @@ function delayClass(ms: number | null): string {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.acts {
|
||||
display: flex;
|
||||
gap: var(--s-2);
|
||||
margin-bottom: var(--s-3);
|
||||
}
|
||||
|
||||
.acts button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--s-1);
|
||||
padding: var(--s-1) var(--s-3);
|
||||
border: 1px solid var(--c-border-strong);
|
||||
border-radius: var(--r-sm);
|
||||
background: var(--c-surface);
|
||||
font-size: var(--t-sm);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.acts button:hover:not(:disabled) {
|
||||
border-color: var(--c-accent);
|
||||
color: var(--c-accent-text);
|
||||
}
|
||||
|
||||
.acts button.danger:hover:not(:disabled) {
|
||||
border-color: var(--c-danger);
|
||||
color: var(--c-danger);
|
||||
}
|
||||
|
||||
.acts button:disabled {
|
||||
color: var(--c-text-faint);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.locked-note {
|
||||
margin: var(--s-4) 0 0;
|
||||
}
|
||||
|
||||
.pick {
|
||||
padding-top: var(--s-4);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user