index.tsx 3.8 KB

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