Spaces:
Sleeping
Sleeping
Download api-client/theme/queries.ts from KazukiWatanabe/FE_Dev: direct link, hf CLI and curl.
- Browser
- Download file 957 Bytes
-
https://huggingface.co/spaces/KazukiWatanabe/FE_Dev/resolve/main/api-client/theme/queries.ts
- Command line
-
hf download hf://spaces/KazukiWatanabe/FE_Dev/api-client/theme/queries.ts
-
curl -L -o queries.ts https://huggingface.co/spaces/KazukiWatanabe/FE_Dev/resolve/main/api-client/theme/queries.ts
957 Bytes
| import { createQueryOptions } from '@/api-client/query-config'; | |
| import type { ThemeExtractionResult } from '@/schema/theme-extraction'; | |
| import { useQuery } from '@tanstack/react-query'; | |
| import { generateThemeCss, type GenerateThemeCssResponse } from './index'; | |
| /** | |
| * テーマCSS生成フック | |
| * テーマデータが渡された場合のみCSS生成を実行 | |
| */ | |
| export function useThemeCss(themeData: ThemeExtractionResult | null, enabled: boolean = true) { | |
| return useQuery<GenerateThemeCssResponse>({ | |
| ...createQueryOptions<GenerateThemeCssResponse>(), | |
| queryKey: ['themeCss', themeData ? JSON.stringify(themeData) : 'no-theme'], | |
| queryFn: () => { | |
| if (!themeData) { | |
| return { | |
| success: true, | |
| css: undefined, | |
| }; | |
| } | |
| return generateThemeCss(themeData); | |
| }, | |
| enabled: enabled && !!themeData, | |
| staleTime: Infinity, // テーマデータが同じならキャッシュを使う | |
| }); | |
| } | |