feat: admin apikeys

This commit is contained in:
jialin
2026-04-17 20:35:16 +08:00
committed by jialin
parent f45d9bda61
commit 2d726ded30
8 changed files with 114 additions and 36 deletions
@@ -0,0 +1,36 @@
import { useQueryDataList } from '@/hooks/use-query-data-list';
import { useModel } from '@@/plugin-model';
import { queryUsersList } from '../apis';
import { ListItem } from '../config/types';
export const useQueryUserList = (optons?: {
getLabel?: (item: ListItem) => string;
getValue?: (item: ListItem) => any;
}) => {
const { initialState } = useModel('@@initialState');
const { dataList, loading, fetchData, cancelRequest } = useQueryDataList<
ListItem,
Global.SearchParams
>({
key: 'userList',
fetchList: queryUsersList,
getLabel: optons?.getLabel,
getValue: optons?.getValue
});
const fetchUserList = (params: Global.SearchParams) => {
if (!initialState?.currentUser?.is_admin) return;
return fetchData({
...params
});
};
return {
dataList,
loading,
fetchData: fetchUserList,
cancelRequest
};
};
export default useQueryUserList;