From 67b0771081ca6af49e7fc16104968f9f48425bc9 Mon Sep 17 00:00:00 2001 From: Joel Date: Mon, 17 Nov 2025 18:21:43 +0800 Subject: [PATCH] fix: try app not ok in chat --- web/app/components/base/chat/embedded-chatbot/hooks.tsx | 9 +++++++-- web/app/components/base/chat/embedded-chatbot/index.tsx | 3 ++- web/service/use-try-app.ts | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/web/app/components/base/chat/embedded-chatbot/hooks.tsx b/web/app/components/base/chat/embedded-chatbot/hooks.tsx index ea1f4c54f5..90a565c302 100644 --- a/web/app/components/base/chat/embedded-chatbot/hooks.tsx +++ b/web/app/components/base/chat/embedded-chatbot/hooks.tsx @@ -37,6 +37,7 @@ import { TransferMethod } from '@/types/app' import { addFileInfos, sortAgentSorts } from '@/app/components/tools/utils' import { noop } from 'lodash-es' import { useWebAppStore } from '@/context/web-app-context' +import { useGetTryAppInfo, useGetTryAppParams } from '@/service/use-try-app' function getFormattedChatList(messages: any[]) { const newChatList: ChatItem[] = [] @@ -67,9 +68,13 @@ function getFormattedChatList(messages: any[]) { export const useEmbeddedChatbot = (appSourceType: AppSourceType, tryAppId?: string) => { const isInstalledApp = false // just can be webapp and try app const isTryApp = appSourceType === AppSourceType.tryApp - const appInfo = useWebAppStore(s => s.appInfo) + const { data: tryAppInfo } = useGetTryAppInfo(isTryApp ? tryAppId! : '') + const webAppInfo = useWebAppStore(s => s.appInfo) + const appInfo = isTryApp ? tryAppInfo : webAppInfo const appMeta = useWebAppStore(s => s.appMeta) - const appParams = useWebAppStore(s => s.appParams) + const { data: tryAppParams } = useGetTryAppParams(isTryApp ? tryAppId! : '') + const webAppParams = useWebAppStore(s => s.appParams) + const appParams = isTryApp ? tryAppParams : webAppParams const appId = useMemo(() => { return isTryApp ? tryAppId : (appInfo as any)?.app_id diff --git a/web/app/components/base/chat/embedded-chatbot/index.tsx b/web/app/components/base/chat/embedded-chatbot/index.tsx index a0192419c2..34215fc8dd 100644 --- a/web/app/components/base/chat/embedded-chatbot/index.tsx +++ b/web/app/components/base/chat/embedded-chatbot/index.tsx @@ -21,6 +21,7 @@ import cn from '@/utils/classnames' import useDocumentTitle from '@/hooks/use-document-title' import { useGlobalPublicStore } from '@/context/global-public-context' import { AppSourceType } from '@/service/share' +import type { AppData } from '@/models/share' const Chatbot = () => { const { @@ -136,7 +137,7 @@ const EmbeddedChatbotWrapper = () => { return { queryFn: () => { return fetchTryAppInfo(appId) }, + enabled: !!appId, }) } @@ -20,6 +21,7 @@ export const useGetTryAppParams = (appId: string) => { queryFn: () => { return fetchAppParams(AppSourceType.tryApp, appId) }, + enabled: !!appId, }) }