This commit is contained in:
Stephen Zhou 2026-05-06 10:27:25 +08:00
parent 58675e967f
commit 72cbf0ae62
No known key found for this signature in database
2 changed files with 18 additions and 6 deletions

View File

@ -1,5 +1,5 @@
import type { WorkflowOnlineUser, WorkflowOnlineUsersResponse } from '@/models/app'
import { skipToken, useQuery } from '@tanstack/react-query'
import { useQuery } from '@tanstack/react-query'
import { consoleQuery } from '@/service/client'
type WorkflowOnlineUsersMap = Record<string, WorkflowOnlineUser[]>
@ -36,9 +36,12 @@ export const useWorkflowOnlineUsers = ({
}: UseWorkflowOnlineUsersParams) => {
const shouldFetch = enabled && appIds.length > 0
const { data: onlineUsersMap = {} } = useQuery(consoleQuery.apps.workflowOnlineUsers.queryOptions({
input: shouldFetch
? { body: { app_ids: appIds } }
: skipToken,
input: {
body: {
app_ids: appIds,
},
},
enabled: shouldFetch,
select: normalizeWorkflowOnlineUsers,
refetchInterval: shouldFetch ? 10000 : false,
}))

View File

@ -7,13 +7,14 @@ import { cn } from '@langgenius/dify-ui/cn'
import { Dialog, DialogCloseButton, DialogContent, DialogDescription, DialogTitle } from '@langgenius/dify-ui/dialog'
import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
import { toast } from '@langgenius/dify-ui/toast'
import { useQuery } from '@tanstack/react-query'
import { useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { AppTypeIcon } from '@/app/components/app/type-selector'
import AppIcon from '@/app/components/base/app-icon'
import Input from '@/app/components/base/input'
import { useRouter } from '@/next/navigation'
import { useAppList } from '@/service/use-apps'
import { consoleQuery } from '@/service/client'
import { useCreateDeploymentInstance } from '../hooks/use-deployment-mutations'
import { useDeploymentsStore } from '../store'
@ -204,7 +205,15 @@ const CreateInstanceForm: FC<{ onClose: () => void }> = ({ onClose }) => {
const { t } = useTranslation('deployments')
const router = useRouter()
const createInstance = useCreateDeploymentInstance()
const { data: appList, isLoading } = useAppList({ page: 1, limit: MAX_STUDIO_SOURCE_APPS, name: '' })
const { data: appList, isLoading } = useQuery(consoleQuery.apps.list.queryOptions({
input: {
query: {
page: 1,
limit: MAX_STUDIO_SOURCE_APPS,
name: '',
},
},
}))
const apps = useMemo<AppInfo[]>(() => {
return (appList?.data ?? []).map(toStudioSourceAppInfo)
}, [appList?.data])