Download apps/web/src/hooks/useTools.ts from hunian003/message: direct link, hf CLI and curl.
- Browser
- Download file 663 Bytes
-
https://huggingface.co/spaces/hunian003/message/resolve/main/apps/web/src/hooks/useTools.ts
- Command line
-
hf download hf://spaces/hunian003/message/apps/web/src/hooks/useTools.ts
-
curl -L -o useTools.ts https://huggingface.co/spaces/hunian003/message/resolve/main/apps/web/src/hooks/useTools.ts
663 Bytes
| /** | |
| * Tool 目录相关 hooks | |
| */ | |
| import { useQuery } from '@tanstack/react-query'; | |
| import { toolsApi } from '@api/tools'; | |
| import { ToolQueryParams } from '@typings/tool'; | |
| import { QUERY_STALE_TIME } from '@lib/constants'; | |
| /** | |
| * 获取 Tool 目录列表 | |
| */ | |
| export function useTools(params?: ToolQueryParams) { | |
| return useQuery({ | |
| queryKey: ['tools', params], | |
| queryFn: () => toolsApi.list(params), | |
| staleTime: QUERY_STALE_TIME, | |
| }); | |
| } | |
| /** | |
| * 获取单个 Tool 详情 | |
| */ | |
| export function useTool(toolName: string) { | |
| return useQuery({ | |
| queryKey: ['tools', toolName], | |
| queryFn: () => toolsApi.get(toolName), | |
| enabled: !!toolName, | |
| }); | |
| } | |