index.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import { useContext } from 'use-context-selector'
  5. import ExploreContext from '@/context/explore-context'
  6. import TextGenerationApp from '@/app/components/share/text-generation'
  7. import Loading from '@/app/components/base/loading'
  8. import ChatWithHistory from '@/app/components/base/chat/chat-with-history'
  9. export type IInstalledAppProps = {
  10. id: string
  11. }
  12. const InstalledApp: FC<IInstalledAppProps> = ({
  13. id,
  14. }) => {
  15. const { installedApps } = useContext(ExploreContext)
  16. const installedApp = installedApps.find(item => item.id === id)
  17. if (!installedApp) {
  18. return (
  19. <div className='flex h-full items-center'>
  20. <Loading type='area' />
  21. </div>
  22. )
  23. }
  24. return (
  25. <div className='h-full py-2 pl-0 pr-2 sm:p-2'>
  26. {installedApp.app.mode !== 'completion' && installedApp.app.mode !== 'workflow' && (
  27. <ChatWithHistory installedAppInfo={installedApp} className='rounded-2xl shadow-md overflow-hidden' />
  28. )}
  29. {installedApp.app.mode === 'completion' && (
  30. <TextGenerationApp isInstalledApp installedAppInfo={installedApp}/>
  31. )}
  32. {installedApp.app.mode === 'workflow' && (
  33. <TextGenerationApp isWorkflow isInstalledApp installedAppInfo={installedApp}/>
  34. )}
  35. </div>
  36. )
  37. }
  38. export default React.memo(InstalledApp)