fix: try app not ok in chat

This commit is contained in:
Joel 2025-11-17 18:21:43 +08:00
parent 9a07488da9
commit 67b0771081
3 changed files with 11 additions and 3 deletions

View File

@ -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

View File

@ -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 <EmbeddedChatbotContext.Provider value={{
appSourceType: AppSourceType.webApp,
appData,
appData: appData as AppData,
appParams,
appMeta,
appChatListDataLoading,

View File

@ -11,6 +11,7 @@ export const useGetTryAppInfo = (appId: string) => {
queryFn: () => {
return fetchTryAppInfo(appId)
},
enabled: !!appId,
})
}
@ -20,6 +21,7 @@ export const useGetTryAppParams = (appId: string) => {
queryFn: () => {
return fetchAppParams(AppSourceType.tryApp, appId)
},
enabled: !!appId,
})
}