diff options
| author | Matain <[email protected]> | 2022-06-08 23:49:07 +0800 |
|---|---|---|
| committer | Matain <[email protected]> | 2022-06-08 23:49:07 +0800 |
| commit | 6a266db1dc3377c96f587fda731c49cb9acf4e3f (patch) | |
| tree | 3ff3ab766cef1c77ddc0d7bf50f06bcf79750986 /src | |
| parent | 68c6be4359f3b37fe71d89357f581567ecd40e12 (diff) | |
| parent | f6e5bdfaa7ea43a193eebdecf9619e6e5ec40919 (diff) | |
Merge branch 'master' of https://github.com/MetaCubeX/yacd
Diffstat (limited to 'src')
| -rw-r--r-- | src/api/proxies.ts | 2 | ||||
| -rw-r--r-- | src/components/proxies/ProxyGroup.tsx | 11 | ||||
| -rw-r--r-- | src/store/app.ts | 2 |
3 files changed, 12 insertions, 3 deletions
diff --git a/src/api/proxies.ts b/src/api/proxies.ts index 3283449..079106b 100644 --- a/src/api/proxies.ts +++ b/src/api/proxies.ts @@ -34,7 +34,7 @@ export async function requestToSwitchProxy(apiConfig, name1, name2) { export async function requestDelayForProxy( apiConfig, name, - latencyTestUrl = 'http://www.gstatic.com/generate_202' + latencyTestUrl = 'http://www.gstatic.com/generate_204' ) { const { url, init } = getURLAndInit(apiConfig); const qs = `timeout=5000&url=${latencyTestUrl}`; diff --git a/src/components/proxies/ProxyGroup.tsx b/src/components/proxies/ProxyGroup.tsx index 49ba2e7..c098b32 100644 --- a/src/components/proxies/ProxyGroup.tsx +++ b/src/components/proxies/ProxyGroup.tsx @@ -1,5 +1,8 @@ import * as React from 'react'; import { Zap } from 'react-feather'; +import { useQuery } from 'react-query'; + +import { fetchVersion } from '$src/api/version'; import * as proxiesAPI from '$src/api/proxies'; import { getCollapsibleIsOpen, getHideUnavailableProxies, getProxySortBy } from '$src/store/app'; @@ -15,6 +18,7 @@ import { ProxyList, ProxyListSummaryView } from './ProxyList'; const { createElement, useCallback, useMemo, useState } = React; + function ZapWrapper() { return ( <div className={s0.zapWrapper}> @@ -44,7 +48,12 @@ function ProxyGroupImpl({ proxies ); - const isSelectable = useMemo(() => ['Selector', 'Fallback'].includes(type) , [type]); + const { data: version } = useQuery(['/version', apiConfig], () => + fetchVersion('/version',apiConfig) + ); + + const isSelectable = useMemo(() => ['Selector', version.meta && 'Fallback'].includes(type) , [type]); + const { app: { updateCollapsibleIsOpen }, // proxies: { requestDelayForProxyGroup }, diff --git a/src/store/app.ts b/src/store/app.ts index e1e7ef4..7262b32 100644 --- a/src/store/app.ts +++ b/src/store/app.ts @@ -159,7 +159,7 @@ const defaultState: StateApp = { selectedClashAPIConfigIndex: 0, clashAPIConfigs: [defaultClashAPIConfig], - latencyTestUrl: 'http://www.gstatic.com/generate_202', + latencyTestUrl: 'http://www.gstatic.com/generate_204', selectedChartStyleIndex: 0, theme: 'dark', |
