fix(proxies): group type does not show UDP

This commit is contained in:
riolu.rs 2023-09-05 01:30:17 +08:00
parent 9973c2042c
commit f0fbe09838
5 changed files with 32 additions and 4 deletions

View File

@ -1,7 +1,7 @@
import { createMemo } from 'solid-js' import { createMemo } from 'solid-js'
import { twMerge } from 'tailwind-merge' import { twMerge } from 'tailwind-merge'
import { Latency } from '~/components' import { Latency } from '~/components'
import { formatProxyType } from '~/helpers' import { filterGroupType, formatProxyType } from '~/helpers'
import { useProxies } from '~/signals' import { useProxies } from '~/signals'
export const ProxyNodeCard = (props: { export const ProxyNodeCard = (props: {
@ -32,7 +32,15 @@ export const ProxyNodeCard = (props: {
)} )}
> >
{formatProxyType(proxyNode()?.type)} {formatProxyType(proxyNode()?.type)}
{proxyNode()?.udp && ' :: udp'} {filterGroupType(proxyNode()?.type) ? (
<span>
{' :: '}
{proxyNode()?.xudp && 'x'}
{proxyNode()?.udp && 'udp'}
</span>
) : (
<span>{proxyNode()?.now}</span>
)}
</div> </div>
<div class="text-xs"> <div class="text-xs">
<Latency name={props.proxyName} /> <Latency name={props.proxyName} />

View File

@ -28,12 +28,27 @@ export const formatProxyType = (type = '') => {
const t = type.toLowerCase() const t = type.toLowerCase()
if (t.includes('shadowsocks')) { if (t.includes('shadowsocks')) {
return t.replace('shadowsocks', 'ss') return 'ss'
} }
return t return t
} }
export const filterGroupType = (type = '') => {
const t = type.toLowerCase()
const conditions = [
'selector',
'direct',
'reject',
'urltest',
'loadbalance',
'fallback',
'relay',
]
return !conditions.includes(t)
}
export const sortProxiesByOrderingType = ( export const sortProxiesByOrderingType = (
proxyNames: string[], proxyNames: string[],
proxyLatencyMap: Record<string, number>, proxyLatencyMap: Record<string, number>,

View File

@ -71,7 +71,7 @@ export default () => {
</Button> </Button>
</div> </div>
<div class="text-sm text-slate-500"> <div class="text-sm text-slate-500">
{proxy.type} :: {proxy.now} {proxy.type} {proxy.now?.length > 0 && ` :: ${proxy.now}`}
</div> </div>
<Show when={!collapsedMap()[`group-${proxy.name}`]}> <Show when={!collapsedMap()[`group-${proxy.name}`]}>
<ProxyNodePreview <ProxyNodePreview

View File

@ -5,6 +5,8 @@ import type { Proxy, ProxyNode, ProxyProvider } from '~/types'
type ProxyInfo = { type ProxyInfo = {
name: string name: string
udp: boolean udp: boolean
now: string
xudp: boolean
type: string type: string
} }
// these signals should be global state // these signals should be global state
@ -25,7 +27,9 @@ const setProxiesInfo = (proxies: (Proxy | ProxyNode)[]) => {
newProxyNodeMap[proxy.name] = { newProxyNodeMap[proxy.name] = {
udp: proxy.udp, udp: proxy.udp,
xudp: proxy.xudp,
type: proxy.type, type: proxy.type,
now: proxy.now,
name: proxy.name, name: proxy.name,
} }
newLatencyMap[proxy.name] = latency newLatencyMap[proxy.name] = latency

View File

@ -28,6 +28,7 @@ export type ProxyNode = {
tfo: boolean tfo: boolean
udp: boolean udp: boolean
xudp: boolean xudp: boolean
now: string
id: string id: string
extra: Record<string, unknown> extra: Record<string, unknown>
history: { history: {