result-text.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. 'use client'
  2. import type { FC } from 'react'
  3. import { useTranslation } from 'react-i18next'
  4. import { ImageIndentLeft } from '@/app/components/base/icons/src/vender/line/editor'
  5. import { Markdown } from '@/app/components/base/markdown'
  6. import LoadingAnim from '@/app/components/app/chat/loading-anim'
  7. type ResultTextProps = {
  8. isRunning?: boolean
  9. outputs?: any
  10. error?: string
  11. onClick?: () => void
  12. }
  13. const ResultText: FC<ResultTextProps> = ({
  14. isRunning,
  15. outputs,
  16. error,
  17. onClick,
  18. }) => {
  19. const { t } = useTranslation()
  20. return (
  21. <div className='bg-gray-50 py-2'>
  22. {isRunning && !outputs && (
  23. <div className='pt-4 pl-[26px]'>
  24. <LoadingAnim type='text' />
  25. </div>
  26. )}
  27. {!isRunning && error && (
  28. <div className='px-4'>
  29. <div className='px-3 py-[10px] rounded-lg !bg-[#fef3f2] border-[0.5px] border-[rbga(0,0,0,0.05)] shadow-xs'>
  30. <div className='text-xs leading-[18px] text-[#d92d20]'>{error}</div>
  31. </div>
  32. </div>
  33. )}
  34. {!isRunning && !outputs && !error && (
  35. <div className='mt-[120px] px-4 py-2 flex flex-col items-center text-[13px] leading-[18px] text-gray-500'>
  36. <ImageIndentLeft className='w-6 h-6 text-gray-400' />
  37. <div className='mr-2'>{t('runLog.resultEmpty.title')}</div>
  38. <div>
  39. {t('runLog.resultEmpty.tipLeft')}
  40. <span onClick={onClick} className='cursor-pointer text-primary-600'>{t('runLog.resultEmpty.link')}</span>
  41. {t('runLog.resultEmpty.tipRight')}
  42. </div>
  43. </div>
  44. )}
  45. {outputs && (
  46. <div className='px-4 py-2'>
  47. <Markdown content={outputs} />
  48. </div>
  49. )}
  50. </div>
  51. )
  52. }
  53. export default ResultText