mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-04-18 08:21:34 +08:00
feat(proxy-groups): integrate useQuery for fetching proxies data
This commit is contained in:
parent
8de1f673c8
commit
2e505f26ae
@ -9,6 +9,7 @@ import {
|
|||||||
Snackbar,
|
Snackbar,
|
||||||
Typography,
|
Typography,
|
||||||
} from '@mui/material'
|
} from '@mui/material'
|
||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
import { useVirtualizer } from '@tanstack/react-virtual'
|
import { useVirtualizer } from '@tanstack/react-virtual'
|
||||||
import { useLockFn } from 'ahooks'
|
import { useLockFn } from 'ahooks'
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
@ -19,7 +20,7 @@ import { BaseEmpty } from '@/components/base'
|
|||||||
import { useProxySelection } from '@/hooks/use-proxy-selection'
|
import { useProxySelection } from '@/hooks/use-proxy-selection'
|
||||||
import { useVerge } from '@/hooks/use-verge'
|
import { useVerge } from '@/hooks/use-verge'
|
||||||
import { useAppData } from '@/providers/app-data-context'
|
import { useAppData } from '@/providers/app-data-context'
|
||||||
import { updateProxyChainConfigInRuntime } from '@/services/cmds'
|
import { calcuProxies, updateProxyChainConfigInRuntime } from '@/services/cmds'
|
||||||
import delayManager from '@/services/delay'
|
import delayManager from '@/services/delay'
|
||||||
import { debugLog } from '@/utils/debug'
|
import { debugLog } from '@/utils/debug'
|
||||||
|
|
||||||
@ -49,6 +50,17 @@ interface ProxyChainItem {
|
|||||||
export const ProxyGroups = (props: Props) => {
|
export const ProxyGroups = (props: Props) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { mode, isChainMode = false, chainConfigData } = props
|
const { mode, isChainMode = false, chainConfigData } = props
|
||||||
|
|
||||||
|
useQuery({
|
||||||
|
queryKey: ['getProxies'],
|
||||||
|
queryFn: calcuProxies,
|
||||||
|
refetchInterval: 3000,
|
||||||
|
refetchIntervalInBackground: false,
|
||||||
|
staleTime: 1500,
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
refetchOnReconnect: false,
|
||||||
|
})
|
||||||
|
|
||||||
const [proxyChain, setProxyChain] = useState<ProxyChainItem[]>(() => {
|
const [proxyChain, setProxyChain] = useState<ProxyChainItem[]>(() => {
|
||||||
try {
|
try {
|
||||||
const saved = localStorage.getItem('proxy-chain-items')
|
const saved = localStorage.getItem('proxy-chain-items')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user