出站选项改成卡片,带协议和延迟

参照 fl-clash:一张卡三行——名字、协议(策略组显示「类型(当前选中)」)、最近一次延迟。
延迟按 200/500 毫秒分三档着色,没测过就留空而不是显示 0。
这些数据配置文件里都没有,全部来自内核的 /proxies。

另外主区最大宽度从 960 提到 1600,去掉选中行的左侧高亮条。
This commit is contained in:
im0o
2026-08-10 12:09:03 +08:00
parent 206e14c7e7
commit 69ae918e7c
4 changed files with 225 additions and 80 deletions
+23
View File
@@ -72,6 +72,23 @@ export interface ApplyFailure {
restored: boolean
}
export interface ProxyInfo {
/** 协议类型(Vmess、Vless…)或策略组类型(Selector、URLTest…) */
type: string
/** 策略组当前选中的成员。不是策略组就没有这个字段 */
now?: string
/** 策略组的成员列表 */
all?: string[]
/** 延迟测试记录,最后一条是最近一次。delay 为 0 表示测失败 */
history?: { delay: number }[]
}
/** 最近一次延迟。没测过或测失败都返回 null。 */
export function latestDelay(info: ProxyInfo | undefined): number | null {
const last = info?.history?.at(-1)?.delay
return last === undefined || last === 0 ? null : last
}
export const api = {
readConfig: () => request<ConfigSnapshot>('GET', '/api/config'),
@@ -85,6 +102,12 @@ export const api = {
kernel: () => request<{ online: boolean; version?: string }>('GET', '/api/kernel'),
/**
* 所有出站的运行时状态:协议类型、策略组当前选中了谁、最近一次延迟。
* 这些配置文件里都没有,只能问运行中的内核。
*/
proxies: () => request<{ proxies: Record<string, ProxyInfo> }>('GET', '/api/kernel/proxies'),
/** 订阅里当前有哪些线路。配置文件给不出这个答案,只能问运行中的内核。 */
providers: () =>
request<{ providers: Record<string, { vehicleType: string; proxies: { name: string }[] }> }>(