mirror of
https://github.com/langgenius/dify.git
synced 2026-07-27 06:58:30 +08:00
20 lines
705 B
TypeScript
20 lines
705 B
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
import { MARKETPLACE_API_PREFIX } from '@/config'
|
|
import { marketplaceQuery } from './client'
|
|
|
|
export const useMarketplaceTemplateDetail = (templateId: string | null) => {
|
|
return useQuery({
|
|
...marketplaceQuery.templateDetail.queryOptions({
|
|
input: { params: { templateId: templateId ?? '' } },
|
|
}),
|
|
enabled: !!templateId,
|
|
})
|
|
}
|
|
|
|
export const fetchMarketplaceTemplateDSL = async (templateId: string): Promise<string> => {
|
|
const url = `${MARKETPLACE_API_PREFIX}/templates/${templateId}/dsl`
|
|
const response = await fetch(url)
|
|
if (!response.ok) throw new Error(`Failed to fetch DSL: ${response.statusText}`)
|
|
return response.text()
|
|
}
|