index.tsx 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. 'use client'
  2. import { useTranslation } from 'react-i18next'
  3. import classNames from 'classnames'
  4. import Link from 'next/link'
  5. import { useContext } from 'use-context-selector'
  6. import s from './index.module.css'
  7. import Modal from '@/app/components/base/modal'
  8. import { XClose } from '@/app/components/base/icons/src/vender/line/general'
  9. import { Dify } from '@/app/components/base/icons/src/public/common'
  10. import type { LangGeniusVersionResponse } from '@/models/common'
  11. import { IS_CE_EDITION } from '@/config'
  12. import I18n from '@/context/i18n'
  13. type IAccountSettingProps = {
  14. langeniusVersionInfo: LangGeniusVersionResponse
  15. onCancel: () => void
  16. }
  17. const buttonClassName = `
  18. shrink-0 flex items-center h-8 px-3 rounded-lg border border-gray-200
  19. text-xs text-gray-800 font-medium
  20. `
  21. export default function AccountAbout({
  22. langeniusVersionInfo,
  23. onCancel,
  24. }: IAccountSettingProps) {
  25. const { t } = useTranslation()
  26. const { locale } = useContext(I18n)
  27. const isLatest = langeniusVersionInfo.current_version === langeniusVersionInfo.latest_version
  28. return (
  29. <Modal
  30. isShow
  31. onClose={() => { }}
  32. className={s.modal}
  33. >
  34. <div className='relative'>
  35. <div className='absolute -top-2 -right-4 flex justify-center items-center w-8 h-8 cursor-pointer' onClick={onCancel}>
  36. <XClose className='w-4 h-4 text-gray-500' />
  37. </div>
  38. <div>
  39. <div className={classNames(
  40. s['logo-icon'],
  41. 'mx-auto mb-3 w-12 h-12 bg-white rounded-xl border-[0.5px] border-gray-200',
  42. )} />
  43. <Dify className='mx-auto mb-2' />
  44. <div className='mb-3 text-center text-xs font-normal text-gray-500'>Version {langeniusVersionInfo?.current_version}</div>
  45. <div className='mb-4 text-center text-xs font-normal text-gray-700'>
  46. <div>© 2023 LangGenius, Inc., Contributors.</div>
  47. <div className='text-[#1C64F2]'>
  48. {
  49. IS_CE_EDITION
  50. ? <Link href={'https://github.com/langgenius/dify/blob/main/LICENSE'} target='_blank'>Open Source License</Link>
  51. : <>
  52. <Link href={locale === 'en' ? 'https://docs.dify.ai/user-agreement/privacy-policy' : 'https://docs.dify.ai/v/zh-hans/yong-hu-xie-yi/yin-si-xie-yi'} target='_blank'>Privacy Policy</Link>,
  53. <Link href={locale === 'en' ? 'https://docs.dify.ai/user-agreement/terms-of-service' : 'https://docs.dify.ai/v/zh-hans/yong-hu-xie-yi/fu-wu-xie-yi'} target='_blank'>Terms of Service</Link>
  54. </>
  55. }
  56. </div>
  57. </div>
  58. </div>
  59. <div className='mb-4 -mx-8 h-[0.5px] bg-gray-200' />
  60. <div className='flex justify-between items-center'>
  61. <div className='text-xs font-medium text-gray-800'>
  62. {
  63. isLatest
  64. ? t('common.about.latestAvailable', { version: langeniusVersionInfo.latest_version })
  65. : t('common.about.nowAvailable', { version: langeniusVersionInfo.latest_version })
  66. }
  67. </div>
  68. <div className='flex items-center'>
  69. <Link
  70. className={classNames(buttonClassName, 'mr-2')}
  71. href={'https://github.com/langgenius/dify/releases'}
  72. target='_blank'
  73. >
  74. {t('common.about.changeLog')}
  75. </Link>
  76. {
  77. !isLatest && !IS_CE_EDITION && (
  78. <Link
  79. className={classNames(buttonClassName, 'text-primary-600')}
  80. href={langeniusVersionInfo.release_notes}
  81. target='_blank'
  82. >
  83. {t('common.about.updateNow')}
  84. </Link>
  85. )
  86. }
  87. </div>
  88. </div>
  89. </div>
  90. </Modal>
  91. )
  92. }