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.
32 lines
952 B
32 lines
952 B
/**
|
|
* 薪资计算页「更多工具」入口 hook。
|
|
* 入口清单由接口层下发(含路由),页面只负责渲染与跳转。
|
|
*/
|
|
import { fetchSalaryToolLinks } from '../api';
|
|
import type { SalaryToolLink } from '../types';
|
|
import { useAsyncData } from './useAsyncData';
|
|
|
|
export interface UseSalaryToolLinksReturn {
|
|
/** 工具入口数组;未加载完成时为空数组,页面可安全 map */
|
|
tools: SalaryToolLink[];
|
|
/** 加载中 */
|
|
loading: boolean;
|
|
/** 加载失败 */
|
|
error: Error | null;
|
|
/** 重新获取 */
|
|
refresh: () => void;
|
|
}
|
|
|
|
// fetcher 定义在模块级,保证引用稳定(放进组件内会让 useAsyncData 的 effect 反复触发)
|
|
const fetchTools = () => fetchSalaryToolLinks();
|
|
|
|
export function useSalaryToolLinks(): UseSalaryToolLinksReturn {
|
|
const { data, loading, error, refresh } = useAsyncData(fetchTools);
|
|
|
|
return {
|
|
tools: data ?? [],
|
|
loading,
|
|
error,
|
|
refresh,
|
|
};
|
|
}
|
|
|