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