mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-12-26 19:24:12 +08:00
feat: preview dlspeed in proxies page (#924)
This commit is contained in:
parent
8a778f5374
commit
51a88b506c
@ -4,6 +4,7 @@ import {
|
||||
IconReload,
|
||||
IconSettings,
|
||||
} from '@tabler/icons-solidjs'
|
||||
import byteSize from 'byte-size'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
import {
|
||||
Button,
|
||||
@ -24,6 +25,7 @@ import {
|
||||
hideUnAvailableProxies,
|
||||
proxiesOrderingType,
|
||||
renderProxiesInTwoColumns,
|
||||
useConnections,
|
||||
useProxies,
|
||||
} from '~/signals'
|
||||
|
||||
@ -60,6 +62,8 @@ export default () => {
|
||||
updatingMap,
|
||||
} = useProxies()
|
||||
|
||||
const { speedGroupByName } = useConnections()
|
||||
|
||||
const [collapsedMap, setCollapsedMap] = makePersisted(
|
||||
createSignal<Record<string, boolean>>({}),
|
||||
{
|
||||
@ -210,7 +214,11 @@ export default () => {
|
||||
|
||||
<div class="text-sm text-slate-500">
|
||||
{proxyGroup.type}{' '}
|
||||
{proxyGroup.now?.length > 0 && ` :: ${proxyGroup.now}`}
|
||||
{proxyGroup.now?.length > 0 && ` :: ${proxyGroup.now}`}{' '}
|
||||
{byteSize(
|
||||
speedGroupByName()[proxyGroup.name] ?? 0,
|
||||
).toString()}
|
||||
/s
|
||||
</div>
|
||||
|
||||
<Show when={!collapsedMap()[proxyGroup.name]}>
|
||||
|
@ -25,6 +25,7 @@ export const [quickFilterRegex, setQuickFilterRegex] = makePersisted(
|
||||
export const [allConnections, setAllConnections] = createSignal<Connection[]>(
|
||||
[],
|
||||
)
|
||||
|
||||
export const [latestConnectionMsg, setLatestConnectionMsg] =
|
||||
createSignal<WsMsg>(null)
|
||||
|
||||
@ -69,9 +70,26 @@ export const useConnections = () => {
|
||||
})
|
||||
})
|
||||
|
||||
const speedGroupByName = createMemo(() => {
|
||||
const returnMap: Record<string, number> = {}
|
||||
|
||||
activeConnections().forEach((c) => {
|
||||
c.chains.forEach((chain) => {
|
||||
if (!returnMap[chain]) {
|
||||
returnMap[chain] = 0
|
||||
}
|
||||
|
||||
returnMap[chain] += c.downloadSpeed
|
||||
})
|
||||
})
|
||||
|
||||
return returnMap
|
||||
})
|
||||
|
||||
return {
|
||||
closedConnections,
|
||||
activeConnections,
|
||||
speedGroupByName,
|
||||
paused,
|
||||
setPaused,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user