轻松聘
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
757 B

/**
* 关于我们 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,
};
}