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
827 B
30 lines
827 B
/**
|
|
* 账号与安全 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,
|
|
};
|
|
}
|
|
|