/** * 账号与安全 hook:拉取账号安全操作项列表(绑定手机 / 微信 / 改密 / 注销等)。 */ import { useCallback } from 'react'; import { fetchAccountSecurity } from '../api'; import type { ActionSetting } from '../types'; import { useAsyncData } from './useAsyncData'; export interface AccountSecurityState { /** 操作项列表 */ items: ActionSetting[]; /** 是否加载中 */ loading: boolean; /** 错误对象 */ error: Error | null; /** 刷新数据 */ refresh: () => void; } export function useAccountSecurity(): AccountSecurityState { const fetcher = useCallback(() => fetchAccountSecurity(), []); const { data, loading, error, refresh } = useAsyncData(fetcher); return { items: (data as ActionSetting[] | null) ?? [], loading, error, refresh, }; }