/** * 关于我们 hook:拉取应用版本、公司主体与协议链接。 */ import { useCallback } from 'react'; import { fetchAboutInfo } from '../api'; import type { AboutInfo } from '../types'; import { useAsyncData } from './useAsyncData'; export interface AboutInfoState { /** 关于我们信息 */ about: AboutInfo | null; /** 是否加载中 */ loading: boolean; /** 错误对象 */ error: Error | null; /** 刷新数据 */ refresh: () => void; } export function useAboutInfo(): AboutInfoState { const fetcher = useCallback(() => fetchAboutInfo(), []); const { data, loading, error, refresh } = useAsyncData(fetcher); return { about: (data as AboutInfo | null) ?? null, loading, error, refresh, }; }