Files
OpenFlare/frontend/hooks/use-public-config.ts
T
ryan a44043262e perf(frontend): split admin bundles and tighten data fetching
Add next/dynamic lazy loading for database, logs, and settings heavy
modules; migrate access-logs and task-executions to React Query; parallelize
login auth-sources with public config; consolidate users table tooltips;
enable lazy image decoding; and replace barrel @/lib/services imports with
direct module paths.
2026-06-17 12:12:47 +08:00

21 lines
570 B
TypeScript

import {useQuery} from '@tanstack/react-query'
import {ConfigService} from '@/lib/services/config'
/**
* 获取公共配置(使用 React Query 进行统一缓存与自动同步)
*
* @example
* ```tsx
* const { config, loading, error } = usePublicConfig()
* ```
*/
export function usePublicConfig() {
const { data: config, isLoading: loading, error } = useQuery({
queryKey: ['public-config'],
queryFn: () => ConfigService.getPublicConfig(),
staleTime: 5 * 60 * 1000, // 5 分钟缓存
})
return { config: config || null, loading, error }
}