mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-10 05:15:35 +08:00
fix: better update provider all
This commit is contained in:
parent
419d3e33f3
commit
68ef377f4b
@ -14,6 +14,7 @@ export default () => {
|
||||
const {
|
||||
proxyProviders,
|
||||
updateProviderByProviderName,
|
||||
updateAllProvider,
|
||||
healthCheckByProviderName,
|
||||
} = useProxies()
|
||||
|
||||
@ -41,13 +42,10 @@ export default () => {
|
||||
|
||||
const onUpdateAllProviderClick = async (e: MouseEvent) => {
|
||||
const el = e.target as HTMLElement
|
||||
const list = proxyProviders().map((provider) => {
|
||||
return updateProviderByProviderName(provider.name)
|
||||
})
|
||||
|
||||
el.classList.add('animate-spin')
|
||||
e.stopPropagation()
|
||||
await Promise.all(list)
|
||||
await updateAllProvider()
|
||||
el.classList.remove('animate-spin')
|
||||
}
|
||||
|
||||
|
@ -109,6 +109,15 @@ export function useProxies() {
|
||||
await updateProxy()
|
||||
}
|
||||
|
||||
const updateAllProvider = async () => {
|
||||
await Promise.all(
|
||||
proxyProviders().map((provider) => {
|
||||
return request.put(`providers/proxies/${provider.name}`)
|
||||
}),
|
||||
)
|
||||
await updateProxy()
|
||||
}
|
||||
|
||||
const healthCheckByProviderName = async (providerName: string) => {
|
||||
await request.get(`providers/proxies/${providerName}/healthcheck`, {
|
||||
timeout: 30 * 1000, // thie api was a little bit slow sometimes...
|
||||
@ -125,6 +134,7 @@ export function useProxies() {
|
||||
updateProxy,
|
||||
setProxyGroupByProxyName,
|
||||
updateProviderByProviderName,
|
||||
updateAllProvider,
|
||||
healthCheckByProviderName,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user