mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-03 21:52:11 +08:00
fix: eliminate error flash on startup by distinguishing loading from error state
- Change TQ_MIHOMO retryDelay from fixed 2000ms to exponential backoff (200ms → 400ms → 800ms, cap 3s) so core-dependent queries retry faster - Expose isCoreDataPending from AppDataProvider to distinguish between data still loading vs actual errors - ClashModeCard: show placeholder instead of "communication error" while core data is pending - CurrentProxyCard: show empty space instead of "no active node" while core data is pending
This commit is contained in:
@@ -16,6 +16,7 @@ export interface AppDataContextType {
|
||||
proxyProviders: Record<string, ProxyProvider>
|
||||
ruleProviders: Record<string, RuleProvider>
|
||||
systemProxyAddress: string
|
||||
isCoreDataPending: boolean
|
||||
|
||||
refreshProxy: () => Promise<any>
|
||||
refreshClashConfig: () => Promise<any>
|
||||
|
||||
@@ -23,7 +23,7 @@ const TQ_MIHOMO = {
|
||||
refetchOnReconnect: false,
|
||||
staleTime: 1500,
|
||||
retry: 3,
|
||||
retryDelay: 2000,
|
||||
retryDelay: (attempt: number) => Math.min(200 * 2 ** attempt, 3000),
|
||||
} as const
|
||||
|
||||
const TQ_DEFAULTS = {
|
||||
@@ -41,13 +41,21 @@ export const AppDataProvider = ({
|
||||
}) => {
|
||||
const { verge } = useVerge()
|
||||
|
||||
const { data: proxiesData, refetch: refreshProxy } = useQuery({
|
||||
const {
|
||||
data: proxiesData,
|
||||
isPending: isProxiesPending,
|
||||
refetch: refreshProxy,
|
||||
} = useQuery({
|
||||
queryKey: ['getProxies'],
|
||||
queryFn: calcuProxies,
|
||||
...TQ_MIHOMO,
|
||||
})
|
||||
|
||||
const { data: clashConfig, refetch: refreshClashConfig } = useQuery({
|
||||
const {
|
||||
data: clashConfig,
|
||||
isPending: isClashConfigPending,
|
||||
refetch: refreshClashConfig,
|
||||
} = useQuery({
|
||||
queryKey: ['getClashConfig'],
|
||||
queryFn: getBaseConfig,
|
||||
...TQ_MIHOMO,
|
||||
@@ -323,6 +331,9 @@ export const AppDataProvider = ({
|
||||
|
||||
systemProxyAddress: calculateSystemProxyAddress(),
|
||||
|
||||
// core 数据加载状态
|
||||
isCoreDataPending: isProxiesPending || isClashConfigPending,
|
||||
|
||||
// 刷新方法
|
||||
refreshProxy,
|
||||
refreshClashConfig,
|
||||
@@ -335,6 +346,8 @@ export const AppDataProvider = ({
|
||||
}, [
|
||||
proxiesData,
|
||||
clashConfig,
|
||||
isProxiesPending,
|
||||
isClashConfigPending,
|
||||
rulesData,
|
||||
sysproxy,
|
||||
runningMode,
|
||||
|
||||
Reference in New Issue
Block a user