mirror of
https://github.com/langgenius/dify.git
synced 2026-05-01 07:58:02 +08:00
app list filter
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { get } from './base'
|
||||
import type { App } from '@/types/app'
|
||||
import type { AppListResponse } from '@/models/app'
|
||||
import { useInvalid } from './use-base'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
|
||||
@ -8,9 +9,9 @@ const NAME_SPACE = 'apps'
|
||||
// TODO paging for list
|
||||
const useAppFullListKey = [NAME_SPACE, 'full-list']
|
||||
export const useAppFullList = () => {
|
||||
return useQuery<App[]>({
|
||||
return useQuery<AppListResponse>({
|
||||
queryKey: useAppFullListKey,
|
||||
queryFn: () => get<App[]>('/apps', { params: { page: 1, limit: 100 } }),
|
||||
queryFn: () => get<AppListResponse>('/apps', { params: { page: 1, limit: 100 } }),
|
||||
})
|
||||
}
|
||||
|
||||
@ -21,6 +22,10 @@ export const useInvalidateAppFullList = () => {
|
||||
export const useAppDetail = (appID: string) => {
|
||||
return useQuery<App>({
|
||||
queryKey: [NAME_SPACE, 'detail', appID],
|
||||
queryFn: () => get<App>(`/apps/${appID}`),
|
||||
queryFn: () => {
|
||||
if (appID === 'empty')
|
||||
return Promise.resolve(undefined as unknown as App)
|
||||
return get<App>(`/apps/${appID}`)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user