index.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {
  2. memo,
  3. useRef,
  4. } from 'react'
  5. import { useKeyPress } from 'ahooks'
  6. import { useTranslation } from 'react-i18next'
  7. import ChatWrapper from './chat-wrapper'
  8. import Button from '@/app/components/base/button'
  9. import { RefreshCcw01 } from '@/app/components/base/icons/src/vender/line/arrows'
  10. export type ChatWrapperRefType = {
  11. handleRestart: () => void
  12. }
  13. const DebugAndPreview = () => {
  14. const { t } = useTranslation()
  15. const chatRef = useRef({ handleRestart: () => {} })
  16. useKeyPress('shift.r', () => {
  17. chatRef.current.handleRestart()
  18. }, {
  19. exactMatch: true,
  20. })
  21. return (
  22. <div
  23. className={`
  24. flex flex-col w-[400px] rounded-l-2xl h-full border border-black/[0.02] shadow-xl
  25. `}
  26. style={{
  27. background: 'linear-gradient(156deg, rgba(242, 244, 247, 0.80) 0%, rgba(242, 244, 247, 0.00) 99.43%), var(--white, #FFF)',
  28. }}
  29. >
  30. <div className='shrink-0 flex items-center justify-between px-4 pt-3 pb-2 font-semibold text-gray-900'>
  31. {t('workflow.common.debugAndPreview').toLocaleUpperCase()}
  32. <Button
  33. className='pl-2.5 pr-[7px] h-8 bg-white border-[0.5px] border-gray-200 shadow-xs rounded-lg text-[13px] text-primary-600 font-semibold'
  34. onClick={() => chatRef.current.handleRestart()}
  35. >
  36. <RefreshCcw01 className='mr-1 w-3.5 h-3.5' />
  37. {t('common.operation.refresh')}
  38. <div className='ml-2 px-1 leading-[18px] rounded-md border border-gray-200 bg-gray-50 text-[11px] text-gray-500 font-medium'>Shift</div>
  39. <div className='ml-0.5 px-1 leading-[18px] rounded-md border border-gray-200 bg-gray-50 text-[11px] text-gray-500 font-medium'>R</div>
  40. </Button>
  41. </div>
  42. <div className='grow rounded-b-2xl overflow-y-auto'>
  43. <ChatWrapper ref={chatRef} />
  44. </div>
  45. </div>
  46. )
  47. }
  48. export default memo(DebugAndPreview)