index.tsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 ChatApp from '@/app/components/share/chat'
  7. import TextGenerationApp from '@/app/components/share/text-generation'
  8. import Loading from '@/app/components/base/loading'
  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 p-2'>
  26. {installedApp?.app.mode === 'chat'
  27. ? (
  28. <ChatApp isInstalledApp installedAppInfo={installedApp}/>
  29. )
  30. : (
  31. <TextGenerationApp isInstalledApp installedAppInfo={installedApp}/>
  32. )}
  33. </div>
  34. )
  35. }
  36. export default React.memo(InstalledApp)