mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-24 09:45:35 +08:00
feat(proxy): single proxy node latency testing state indicator
This commit is contained in:
parent
8f8a54af0a
commit
0052ce4325
@ -10,7 +10,7 @@ export const ProxyNodeCard = (props: {
|
|||||||
isSelected?: boolean
|
isSelected?: boolean
|
||||||
onClick?: () => void
|
onClick?: () => void
|
||||||
}) => {
|
}) => {
|
||||||
const { proxyLatencyTest } = useProxies()
|
const { proxyLatencyTest, proxyLatencyTestingMap } = useProxies()
|
||||||
const { proxyName, isSelected, onClick } = props
|
const { proxyName, isSelected, onClick } = props
|
||||||
const { proxyNodeMap } = useProxies()
|
const { proxyNodeMap } = useProxies()
|
||||||
const proxyNode = createMemo(() => proxyNodeMap()[proxyName])
|
const proxyNode = createMemo(() => proxyNodeMap()[proxyName])
|
||||||
@ -38,7 +38,14 @@ export const ProxyNodeCard = (props: {
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
class="btn-circle btn-ghost btn-sm"
|
class="btn-circle btn-ghost btn-sm"
|
||||||
icon={<IconBrandSpeedtest />}
|
icon={
|
||||||
|
<IconBrandSpeedtest
|
||||||
|
class={twMerge(
|
||||||
|
proxyLatencyTestingMap()[proxyName] &&
|
||||||
|
'animate-pulse text-success',
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ export default () => {
|
|||||||
proxyProviderLatencyTest,
|
proxyProviderLatencyTest,
|
||||||
collapsedMap,
|
collapsedMap,
|
||||||
setCollapsedMap,
|
setCollapsedMap,
|
||||||
latencyTestingMap,
|
proxyGroupLatencyTestingMap,
|
||||||
healthCheckingMap,
|
proxyProviderLatencyTestingMap,
|
||||||
isAllProviderUpdating,
|
isAllProviderUpdating,
|
||||||
updatingMap,
|
updatingMap,
|
||||||
} = useProxies()
|
} = useProxies()
|
||||||
@ -170,14 +170,16 @@ export default () => {
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
class="btn-circle btn-sm"
|
class="btn-circle btn-sm"
|
||||||
disabled={latencyTestingMap()[proxyGroup.name]}
|
disabled={
|
||||||
|
proxyGroupLatencyTestingMap()[proxyGroup.name]
|
||||||
|
}
|
||||||
onClick={(e) =>
|
onClick={(e) =>
|
||||||
onProxyGroupLatencyTestClick(e, proxyGroup.name)
|
onProxyGroupLatencyTestClick(e, proxyGroup.name)
|
||||||
}
|
}
|
||||||
icon={
|
icon={
|
||||||
<IconBrandSpeedtest
|
<IconBrandSpeedtest
|
||||||
class={twMerge(
|
class={twMerge(
|
||||||
latencyTestingMap()[proxyGroup.name] &&
|
proxyGroupLatencyTestingMap()[proxyGroup.name] &&
|
||||||
'animate-pulse text-success',
|
'animate-pulse text-success',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
@ -264,7 +266,9 @@ export default () => {
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
class="btn btn-circle btn-sm"
|
class="btn btn-circle btn-sm"
|
||||||
disabled={healthCheckingMap()[proxyProvider.name]}
|
disabled={
|
||||||
|
proxyProviderLatencyTestingMap()[proxyProvider.name]
|
||||||
|
}
|
||||||
onClick={(e) =>
|
onClick={(e) =>
|
||||||
onProxyProviderLatencyTestClick(
|
onProxyProviderLatencyTestClick(
|
||||||
e,
|
e,
|
||||||
@ -274,8 +278,9 @@ export default () => {
|
|||||||
icon={
|
icon={
|
||||||
<IconBrandSpeedtest
|
<IconBrandSpeedtest
|
||||||
class={twMerge(
|
class={twMerge(
|
||||||
healthCheckingMap()[proxyProvider.name] &&
|
proxyProviderLatencyTestingMap()[
|
||||||
'animate-pulse text-success',
|
proxyProvider.name
|
||||||
|
] && 'animate-pulse text-success',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,18 @@ type ProxyInfo = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { map: collapsedMap, set: setCollapsedMap } = useStringBooleanMap()
|
const { map: collapsedMap, set: setCollapsedMap } = useStringBooleanMap()
|
||||||
const { map: latencyTestingMap, setWithCallback: setLatencyTestingMap } =
|
const {
|
||||||
useStringBooleanMap()
|
map: proxyLatencyTestingMap,
|
||||||
const { map: healthCheckingMap, setWithCallback: setHealthCheckingMap } =
|
setWithCallback: setProxyLatencyTestingMap,
|
||||||
useStringBooleanMap()
|
} = useStringBooleanMap()
|
||||||
|
const {
|
||||||
|
map: proxyGroupLatencyTestingMap,
|
||||||
|
setWithCallback: setProxyGroupLatencyTestingMap,
|
||||||
|
} = useStringBooleanMap()
|
||||||
|
const {
|
||||||
|
map: proxyProviderLatencyTestingMap,
|
||||||
|
setWithCallback: setProxyProviderLatencyTestingMap,
|
||||||
|
} = useStringBooleanMap()
|
||||||
const { map: updatingMap, setWithCallback: setUpdatingMap } =
|
const { map: updatingMap, setWithCallback: setUpdatingMap } =
|
||||||
useStringBooleanMap()
|
useStringBooleanMap()
|
||||||
const [isAllProviderUpdating, setIsAllProviderUpdating] = createSignal(false)
|
const [isAllProviderUpdating, setIsAllProviderUpdating] = createSignal(false)
|
||||||
@ -123,7 +131,8 @@ export const useProxies = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const proxyLatencyTest = async (proxyName: string) => {
|
const proxyLatencyTest = (proxyName: string) =>
|
||||||
|
setProxyLatencyTestingMap(proxyName, async () => {
|
||||||
const { delay } = await proxyLatencyTestAPI(
|
const { delay } = await proxyLatencyTestAPI(
|
||||||
proxyName,
|
proxyName,
|
||||||
urlForLatencyTest(),
|
urlForLatencyTest(),
|
||||||
@ -134,10 +143,10 @@ export const useProxies = () => {
|
|||||||
...latencyMap,
|
...latencyMap,
|
||||||
[proxyName]: delay,
|
[proxyName]: delay,
|
||||||
}))
|
}))
|
||||||
}
|
})
|
||||||
|
|
||||||
const proxyGroupLatencyTest = async (proxyGroupName: string) =>
|
const proxyGroupLatencyTest = (proxyGroupName: string) =>
|
||||||
setLatencyTestingMap(proxyGroupName, async () => {
|
setProxyGroupLatencyTestingMap(proxyGroupName, async () => {
|
||||||
const newLatencyMap = await proxyGroupLatencyTestAPI(
|
const newLatencyMap = await proxyGroupLatencyTestAPI(
|
||||||
proxyGroupName,
|
proxyGroupName,
|
||||||
urlForLatencyTest(),
|
urlForLatencyTest(),
|
||||||
@ -152,7 +161,7 @@ export const useProxies = () => {
|
|||||||
await fetchProxies()
|
await fetchProxies()
|
||||||
})
|
})
|
||||||
|
|
||||||
const updateProviderByProviderName = async (providerName: string) =>
|
const updateProviderByProviderName = (providerName: string) =>
|
||||||
setUpdatingMap(providerName, async () => {
|
setUpdatingMap(providerName, async () => {
|
||||||
try {
|
try {
|
||||||
await updateProxyProviderAPI(providerName)
|
await updateProxyProviderAPI(providerName)
|
||||||
@ -175,7 +184,7 @@ export const useProxies = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const proxyProviderLatencyTest = (providerName: string) =>
|
const proxyProviderLatencyTest = (providerName: string) =>
|
||||||
setHealthCheckingMap(providerName, async () => {
|
setProxyProviderLatencyTestingMap(providerName, async () => {
|
||||||
await proxyProviderLatencyTest(providerName)
|
await proxyProviderLatencyTest(providerName)
|
||||||
await fetchProxies()
|
await fetchProxies()
|
||||||
})
|
})
|
||||||
@ -183,8 +192,9 @@ export const useProxies = () => {
|
|||||||
return {
|
return {
|
||||||
collapsedMap,
|
collapsedMap,
|
||||||
setCollapsedMap,
|
setCollapsedMap,
|
||||||
latencyTestingMap,
|
proxyLatencyTestingMap,
|
||||||
healthCheckingMap,
|
proxyGroupLatencyTestingMap,
|
||||||
|
proxyProviderLatencyTestingMap,
|
||||||
updatingMap,
|
updatingMap,
|
||||||
isAllProviderUpdating,
|
isAllProviderUpdating,
|
||||||
proxies,
|
proxies,
|
||||||
|
Loading…
Reference in New Issue
Block a user