mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 02:52:07 +08:00
perf: narrow app data subscriptions
This commit is contained in:
@@ -22,7 +22,7 @@ import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { updateProxyProvider } from 'tauri-plugin-mihomo-api'
|
||||
|
||||
import { useAppData } from '@/providers/app-data-context'
|
||||
import { useAppRefreshers, useProxiesData } from '@/providers/app-data-context'
|
||||
import { showNotice } from '@/services/notice-service'
|
||||
import parseTraffic from '@/utils/parse-traffic'
|
||||
|
||||
@@ -48,7 +48,8 @@ const parseExpire = (expire?: number) => {
|
||||
export const ProviderButton = () => {
|
||||
const { t } = useTranslation()
|
||||
const [open, setOpen] = useState(false)
|
||||
const { proxyProviders, refreshProxy, refreshProxyProviders } = useAppData()
|
||||
const { proxyProviders } = useProxiesData()
|
||||
const { refreshProxy, refreshProxyProviders } = useAppRefreshers()
|
||||
const [updating, setUpdating] = useState<Record<string, boolean>>({})
|
||||
|
||||
// 检查是否有提供者
|
||||
|
||||
@@ -40,7 +40,7 @@ import {
|
||||
selectNodeForGroup,
|
||||
} from 'tauri-plugin-mihomo-api'
|
||||
|
||||
import { useAppData } from '@/providers/app-data-context'
|
||||
import { useAppRefreshers, useProxiesData } from '@/providers/app-data-context'
|
||||
import { updateProxyChainConfigInRuntime } from '@/services/cmds'
|
||||
import { debugLog } from '@/utils/debug'
|
||||
|
||||
@@ -251,7 +251,8 @@ export const ProxyChain = ({
|
||||
}: ProxyChainProps) => {
|
||||
const theme = useTheme()
|
||||
const { t } = useTranslation()
|
||||
const { proxies, refreshProxy } = useAppData()
|
||||
const { proxies } = useProxiesData()
|
||||
const { refreshProxy } = useAppRefreshers()
|
||||
const [isConnecting, setIsConnecting] = useState(false)
|
||||
const markUnsavedChanges = useCallback(() => {
|
||||
onMarkUnsavedChanges?.()
|
||||
|
||||
@@ -19,7 +19,7 @@ import { delayGroup, healthcheckProxyProvider } from 'tauri-plugin-mihomo-api'
|
||||
import { BaseEmpty } from '@/components/base'
|
||||
import { useProxySelection } from '@/hooks/use-proxy-selection'
|
||||
import { useVerge } from '@/hooks/use-verge'
|
||||
import { useAppData } from '@/providers/app-data-context'
|
||||
import { useProxiesData } from '@/providers/app-data-context'
|
||||
import { calcuProxies, updateProxyChainConfigInRuntime } from '@/services/cmds'
|
||||
import delayManager from '@/services/delay'
|
||||
import { debugLog } from '@/utils/debug'
|
||||
@@ -57,7 +57,7 @@ export const ProxyGroups = (props: Props) => {
|
||||
const { t } = useTranslation()
|
||||
const { mode, isChainMode = false, chainConfigData } = props
|
||||
|
||||
// Drive 3s polling on the shared TQ cache; data is read via useAppData() below
|
||||
// Drive 3s polling on the shared TQ cache; data is read via granular context below
|
||||
useQuery({
|
||||
queryKey: ['getProxies'],
|
||||
queryFn: calcuProxies,
|
||||
@@ -95,7 +95,7 @@ export const ProxyGroups = (props: Props) => {
|
||||
}>({ open: false, message: '' })
|
||||
|
||||
const { verge } = useVerge()
|
||||
const { proxies: proxiesData } = useAppData()
|
||||
const { proxies: proxiesData } = useProxiesData()
|
||||
const groups = proxiesData?.groups
|
||||
const availableGroups = useMemo(() => {
|
||||
if (!groups) return []
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useRef } from 'react'
|
||||
|
||||
import { useRuntimeConfig } from '@/hooks/use-clash'
|
||||
import { useVerge } from '@/hooks/use-verge'
|
||||
import { useAppData } from '@/providers/app-data-context'
|
||||
import { useAppRefreshers, useProxiesData } from '@/providers/app-data-context'
|
||||
import delayManager from '@/services/delay'
|
||||
import { debugLog } from '@/utils/debug'
|
||||
|
||||
@@ -108,7 +108,8 @@ export const useRenderList = (
|
||||
selectedGroup?: string | null,
|
||||
) => {
|
||||
// 使用全局数据提供者
|
||||
const { proxies: proxiesData, refreshProxy } = useAppData()
|
||||
const { proxies: proxiesData } = useProxiesData()
|
||||
const { refreshProxy } = useAppRefreshers()
|
||||
const { verge } = useVerge()
|
||||
const { width } = useWindowWidth()
|
||||
const [headStates, setHeadState] = useHeadStateNew()
|
||||
|
||||
Reference in New Issue
Block a user