您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

index.tsx 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { useTheme } from 'next-themes'
  2. import {
  3. RiArrowRightUpLine,
  4. RiArrowUpDoubleLine,
  5. } from '@remixicon/react'
  6. import { useTranslation } from 'react-i18next'
  7. import type { useMarketplace } from './hooks'
  8. import List from '@/app/components/plugins/marketplace/list'
  9. import Loading from '@/app/components/base/loading'
  10. import { getLocaleOnClient } from '@/i18n-config'
  11. import { getMarketplaceUrl } from '@/utils/var'
  12. type MarketplaceProps = {
  13. searchPluginText: string
  14. filterPluginTags: string[]
  15. isMarketplaceArrowVisible: boolean
  16. showMarketplacePanel: () => void
  17. marketplaceContext: ReturnType<typeof useMarketplace>
  18. }
  19. const Marketplace = ({
  20. searchPluginText,
  21. filterPluginTags,
  22. isMarketplaceArrowVisible,
  23. showMarketplacePanel,
  24. marketplaceContext,
  25. }: MarketplaceProps) => {
  26. const locale = getLocaleOnClient()
  27. const { t } = useTranslation()
  28. const { theme } = useTheme()
  29. const {
  30. isLoading,
  31. marketplaceCollections,
  32. marketplaceCollectionPluginsMap,
  33. plugins,
  34. page,
  35. } = marketplaceContext
  36. return (
  37. <>
  38. <div className='sticky bottom-0 flex shrink-0 flex-col bg-background-default-subtle px-12 pb-[14px] pt-2'>
  39. {isMarketplaceArrowVisible && (
  40. <RiArrowUpDoubleLine
  41. className='absolute left-1/2 top-2 z-10 h-4 w-4 -translate-x-1/2 cursor-pointer text-text-quaternary'
  42. onClick={showMarketplacePanel}
  43. />
  44. )}
  45. <div className='pb-3 pt-4'>
  46. <div className='title-2xl-semi-bold bg-gradient-to-r from-[rgba(11,165,236,0.95)] to-[rgba(21,90,239,0.95)] bg-clip-text text-transparent'>
  47. {t('plugin.marketplace.moreFrom')}
  48. </div>
  49. <div className='body-md-regular flex items-center text-center text-text-tertiary'>
  50. {t('plugin.marketplace.discover')}
  51. <span className="body-md-medium relative ml-1 text-text-secondary after:absolute after:bottom-[1.5px] after:left-0 after:h-2 after:w-full after:bg-text-text-selected after:content-['']">
  52. {t('plugin.category.models')}
  53. </span>
  54. ,
  55. <span className="body-md-medium relative ml-1 text-text-secondary after:absolute after:bottom-[1.5px] after:left-0 after:h-2 after:w-full after:bg-text-text-selected after:content-['']">
  56. {t('plugin.category.tools')}
  57. </span>
  58. ,
  59. <span className="body-md-medium relative ml-1 text-text-secondary after:absolute after:bottom-[1.5px] after:left-0 after:h-2 after:w-full after:bg-text-text-selected after:content-['']">
  60. {t('plugin.category.agents')}
  61. </span>
  62. ,
  63. <span className="body-md-medium relative ml-1 mr-1 text-text-secondary after:absolute after:bottom-[1.5px] after:left-0 after:h-2 after:w-full after:bg-text-text-selected after:content-['']">
  64. {t('plugin.category.extensions')}
  65. </span>
  66. {t('plugin.marketplace.and')}
  67. <span className="body-md-medium relative ml-1 mr-1 text-text-secondary after:absolute after:bottom-[1.5px] after:left-0 after:h-2 after:w-full after:bg-text-text-selected after:content-['']">
  68. {t('plugin.category.bundles')}
  69. </span>
  70. {t('common.operation.in')}
  71. <a
  72. href={getMarketplaceUrl('', { language: locale, q: searchPluginText, tags: filterPluginTags.join(','), theme })}
  73. className='system-sm-medium ml-1 flex items-center text-text-accent'
  74. target='_blank'
  75. >
  76. {t('plugin.marketplace.difyMarketplace')}
  77. <RiArrowRightUpLine className='h-4 w-4' />
  78. </a>
  79. </div>
  80. </div>
  81. </div>
  82. <div className='mt-[-14px] shrink-0 grow bg-background-default-subtle px-12 pb-2'>
  83. {
  84. isLoading && page === 1 && (
  85. <div className='absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2'>
  86. <Loading />
  87. </div>
  88. )
  89. }
  90. {
  91. (!isLoading || page > 1) && (
  92. <List
  93. marketplaceCollections={marketplaceCollections || []}
  94. marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap || {}}
  95. plugins={plugins}
  96. showInstallButton
  97. locale={locale}
  98. />
  99. )
  100. }
  101. </div>
  102. </>
  103. )
  104. }
  105. export default Marketplace