fix: better update provider all

This commit is contained in:
Zephyruso 2023-09-02 17:01:59 +08:00
parent 419d3e33f3
commit 68ef377f4b
2 changed files with 12 additions and 4 deletions

View File

@ -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')
}

View File

@ -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,
}
}