mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-18 14:01:56 +08:00
Feature: add meanDelay display
This commit is contained in:
parent
0f141b679c
commit
20978b12b0
@ -49,10 +49,11 @@ export function Proxy (props: ProxyProps) {
|
|||||||
})
|
})
|
||||||
}, [config.name, getDelay, set])
|
}, [config.name, getDelay, set])
|
||||||
|
|
||||||
const delay = useMemo(
|
const delay = config.history?.length ? config.history.slice(-1)[0].delay : 0
|
||||||
() => config.history?.length ? config.history.slice(-1)[0].delay : 0,
|
const meanDelay = config.history?.length ? config.history.slice(-1)[0].meanDelay : undefined
|
||||||
[config],
|
|
||||||
)
|
const delayText = delay === 0 ? '-' : `${delay}ms`
|
||||||
|
const meanDelayText = meanDelay === undefined || meanDelay === 0 ? '' : `(${meanDelay}ms)`
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const handler = () => { speedTest() }
|
const handler = () => { speedTest() }
|
||||||
@ -63,9 +64,9 @@ export function Proxy (props: ProxyProps) {
|
|||||||
const hasError = useMemo(() => delay === 0, [delay])
|
const hasError = useMemo(() => delay === 0, [delay])
|
||||||
const color = useMemo(
|
const color = useMemo(
|
||||||
() => Object.keys(TagColors).find(
|
() => Object.keys(TagColors).find(
|
||||||
threshold => delay <= TagColors[threshold as keyof typeof TagColors],
|
threshold => (meanDelay ?? delay) <= TagColors[threshold as keyof typeof TagColors],
|
||||||
),
|
),
|
||||||
[delay],
|
[delay, meanDelay],
|
||||||
)
|
)
|
||||||
|
|
||||||
const backgroundColor = hasError ? '#E5E7EB' : color
|
const backgroundColor = hasError ? '#E5E7EB' : color
|
||||||
@ -80,7 +81,7 @@ export function Proxy (props: ProxyProps) {
|
|||||||
<p className="proxy-name">{config.name}</p>
|
<p className="proxy-name">{config.name}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col h-full items-center justify-center md:flex-row md:h-[18px] md:justify-between md:space-y-0 space-y-3 text-[10px]">
|
<div className="flex flex-col h-full items-center justify-center md:flex-row md:h-[18px] md:justify-between md:space-y-0 space-y-3 text-[10px]">
|
||||||
<p>{delay === 0 ? '-' : `${delay}ms`}</p>
|
<p >{delayText}{meanDelayText}</p>
|
||||||
{ config.udp && <p className="bg-gray-200 p-[3px] rounded text-gray-600">UDP</p> }
|
{ config.udp && <p className="bg-gray-200 p-[3px] rounded text-gray-600">UDP</p> }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -102,7 +102,7 @@ export default function Settings () {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const controllers = isClashX
|
const controllers = isClashX
|
||||||
? <span>{`${externalControllerHost}:${externalControllerPort}`}</span>
|
? <span className="text-primary-darken text-sm">{`${externalControllerHost}:${externalControllerPort}`}</span>
|
||||||
: (
|
: (
|
||||||
<>
|
<>
|
||||||
<Select
|
<Select
|
||||||
|
@ -52,6 +52,7 @@ export interface ProxyProviders {
|
|||||||
interface History {
|
interface History {
|
||||||
time: string
|
time: string
|
||||||
delay: number
|
delay: number
|
||||||
|
meanDelay?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Proxy {
|
export interface Proxy {
|
||||||
|
@ -1,106 +0,0 @@
|
|||||||
/**
|
|
||||||
* proxy config interface
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const ProxyType = {
|
|
||||||
Shadowsocks: 'ss',
|
|
||||||
Vmess: 'vmess',
|
|
||||||
Socks5: 'socks5',
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Proxy = ShadowsocksProxy & VmessProxy & Socks5Proxy
|
|
||||||
|
|
||||||
export const SsProxyConfigList = [
|
|
||||||
'name', 'type', 'server', 'port', 'cipher', 'password', 'obfs', 'obfs-host',
|
|
||||||
]
|
|
||||||
export interface ShadowsocksProxy {
|
|
||||||
name?: string
|
|
||||||
|
|
||||||
type?: 'ss'
|
|
||||||
|
|
||||||
server?: string
|
|
||||||
|
|
||||||
port?: number
|
|
||||||
|
|
||||||
cipher?: string
|
|
||||||
|
|
||||||
password?: string
|
|
||||||
|
|
||||||
obfs?: string
|
|
||||||
|
|
||||||
'obfs-host'?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export const VmessProxyConfigList = [
|
|
||||||
'name', 'type', 'server', 'port', 'uuid', 'alterid', 'cipher', 'tls',
|
|
||||||
]
|
|
||||||
export interface VmessProxy {
|
|
||||||
name?: string
|
|
||||||
|
|
||||||
type?: 'vmess'
|
|
||||||
|
|
||||||
server?: string
|
|
||||||
|
|
||||||
port?: number
|
|
||||||
|
|
||||||
uuid?: string
|
|
||||||
|
|
||||||
alterId?: number
|
|
||||||
|
|
||||||
cipher?: string
|
|
||||||
|
|
||||||
tls?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Socks5ProxyConfigList = ['name', 'type', 'server', 'port']
|
|
||||||
export interface Socks5Proxy {
|
|
||||||
name?: string
|
|
||||||
|
|
||||||
type?: 'socks5'
|
|
||||||
|
|
||||||
server?: string
|
|
||||||
|
|
||||||
port?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ProxyGroup = SelectProxyGroup & UrlTestProxyGroup & FallbackProxyGroup & LoadBalanceGroup
|
|
||||||
|
|
||||||
export interface SelectProxyGroup {
|
|
||||||
name?: string
|
|
||||||
|
|
||||||
type?: 'select'
|
|
||||||
|
|
||||||
proxies?: string[] // proxy names
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LoadBalanceGroup {
|
|
||||||
name?: string
|
|
||||||
|
|
||||||
type?: 'load-balance'
|
|
||||||
|
|
||||||
proxies?: string[] // proxy names
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FallbackProxyGroup {
|
|
||||||
name?: string
|
|
||||||
|
|
||||||
type?: 'fallback'
|
|
||||||
|
|
||||||
proxies?: string[] // proxy names
|
|
||||||
|
|
||||||
url?: string
|
|
||||||
|
|
||||||
interval?: number // second
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UrlTestProxyGroup {
|
|
||||||
name?: string
|
|
||||||
|
|
||||||
type?: 'url-test'
|
|
||||||
|
|
||||||
proxies?: string[] // proxy names
|
|
||||||
|
|
||||||
url?: string
|
|
||||||
|
|
||||||
interval?: number // second
|
|
||||||
}
|
|
@ -1,5 +1,4 @@
|
|||||||
export * from './BaseProps'
|
export * from './BaseProps'
|
||||||
export * from './Config'
|
export * from './Config'
|
||||||
export * from './Proxy'
|
|
||||||
export * from './Rule'
|
export * from './Rule'
|
||||||
export * from './Cipher'
|
export * from './Cipher'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user