index.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 'use client'
  2. import { useTranslation } from 'react-i18next'
  3. import s from './secret-key/style.module.css'
  4. import Doc from '@/app/components/develop/doc'
  5. import Loading from '@/app/components/base/loading'
  6. import InputCopy from '@/app/components/develop/secret-key/input-copy'
  7. import SecretKeyButton from '@/app/components/develop/secret-key/secret-key-button'
  8. import { useStore as useAppStore } from '@/app/components/app/store'
  9. import { useAppDetailContext } from '@/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main'
  10. type IDevelopMainProps = {
  11. appId: string
  12. }
  13. const DevelopMain = ({ appId }: IDevelopMainProps) => {
  14. const { detail, isCreate, isEdit, isOperation } = useAppDetailContext()
  15. const appDetail = useAppStore(state => state.appDetail)
  16. const { t } = useTranslation()
  17. if (!appDetail) {
  18. return (
  19. <div className='flex h-full items-center justify-center bg-white'>
  20. <Loading />
  21. </div>
  22. )
  23. }
  24. return (
  25. <div className='relative flex h-full flex-col overflow-hidden'>
  26. <div className='flex shrink-0 items-center justify-between border-b border-solid border-b-gray-100 px-6 py-2'>
  27. <div className='text-lg font-medium text-gray-900'></div>
  28. <div className='flex flex-wrap items-center gap-y-1'>
  29. <InputCopy className='mr-1 w-52 shrink-0 sm:w-80' value={appDetail.api_base_url}>
  30. <div className={`ml-2 shrink-0 rounded-[6px] border border-solid border-gray-200 px-2 py-0.5 text-[0.625rem] text-gray-500 ${s.customApi}`}>
  31. {t('appApi.apiServer')}
  32. </div>
  33. </InputCopy>
  34. <div className={`mr-2 flex h-9 items-center rounded-lg
  35. px-3 text-[13px] font-normal ${appDetail.enable_api ? 'bg-green-50 text-green-500' : 'bg-yellow-50 text-yellow-500'}`}>
  36. <div className='mr-1'>{t('appApi.status')}</div>
  37. <div className='font-semibold'>{appDetail.enable_api ? `${t('appApi.ok')}` : `${t('appApi.disabled')}`}</div>
  38. </div>
  39. {
  40. isEdit && (
  41. <SecretKeyButton className='shrink-0' appId={appId} />
  42. )
  43. }
  44. </div>
  45. </div>
  46. <div className='grow overflow-auto px-4 py-4 sm:px-10'>
  47. <Doc appDetail={appDetail} />
  48. </div>
  49. </div>
  50. )
  51. }
  52. export default DevelopMain