refactor: optimize swr data refresh paths

This commit is contained in:
Tunglies
2026-06-28 19:42:21 +08:00
parent e71e701fd0
commit b9da0875cd
16 changed files with 153 additions and 162 deletions
+3 -10
View File
@@ -4,8 +4,7 @@ import { closeAllConnections } from 'tauri-plugin-mihomo-api'
import { useVerge } from '@/hooks/use-verge'
import { useClashConfigData, useSystemData } from '@/providers/app-data-context'
import { getAutotemProxy } from '@/services/cmds'
import { useQuery } from '@/services/query-client'
import { queryClient } from '@/services/query-client'
import { revalidateQueries, useQuery } from '@/services/query-client'
// 系统代理状态检测统一逻辑
export const useSystemProxyState = () => {
@@ -65,18 +64,12 @@ export const useSystemProxyState = () => {
}
} finally {
busyRef.current = false
await Promise.all([
queryClient.invalidateQueries({ queryKey: ['getSystemProxy'] }),
queryClient.invalidateQueries({ queryKey: ['getAutotemProxy'] }),
])
await revalidateQueries([['getSystemProxy'], ['getAutotemProxy']])
}
}
const invalidateProxyState = () =>
Promise.all([
queryClient.invalidateQueries({ queryKey: ['getSystemProxy'] }),
queryClient.invalidateQueries({ queryKey: ['getAutotemProxy'] }),
])
revalidateQueries([['getSystemProxy'], ['getAutotemProxy']])
return {
indicator,