From de0930aba4957bcba8ce867012b9a6dd87cb9e2b Mon Sep 17 00:00:00 2001 From: MetaCubeX Date: Sat, 4 Jun 2022 01:07:54 +0800 Subject: chore: Determine whether FALLBACK is optional based on the core --- src/components/proxies/ProxyGroup.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/components/proxies/ProxyGroup.tsx b/src/components/proxies/ProxyGroup.tsx index c835d7e..8998f27 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 { getCollapsibleIsOpen, @@ -16,6 +19,7 @@ import { ProxyList, ProxyListSummaryView } from './ProxyList'; const { createElement, useCallback, useMemo, useState } = React; + function ZapWrapper() { return (
@@ -45,7 +49,11 @@ 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 }, -- cgit v1.3.1 From f6e5bdfaa7ea43a193eebdecf9619e6e5ec40919 Mon Sep 17 00:00:00 2001 From: MetaCubeX Date: Sat, 4 Jun 2022 01:08:20 +0800 Subject: chore: adjust latencyTestUrl --- src/api/proxies.ts | 2 +- src/store/app.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/api/proxies.ts b/src/api/proxies.ts index 638cddf..ce3266e 100644 --- a/src/api/proxies.ts +++ b/src/api/proxies.ts @@ -33,7 +33,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/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', -- cgit v1.3.1