fix: marketplace submit button

fix/switch-strategy-clean-param
zxhlyh 1 year ago
parent cc0d864599
commit a157af724f

@ -8,7 +8,7 @@ const PluginList = async () => {
return ( return (
<PluginPage <PluginPage
plugins={<PluginsPanel />} plugins={<PluginsPanel />}
marketplace={<Marketplace locale={locale} pluginTypeSwitchClassName='top-[60px]' />} marketplace={<Marketplace locale={locale} pluginTypeSwitchClassName='top-[60px]' searchBoxAutoAnimate={false} />}
/> />
) )
} }

@ -143,3 +143,34 @@ export const useMarketplaceContainerScroll = (
} }
}, [container, handleScroll]) }, [container, handleScroll])
} }
export const useSearchBoxAutoAnimate = (searchBoxAutoAnimate?: boolean) => {
const [searchBoxCanAnimate, setSearchBoxCanAnimate] = useState(true)
const handleSearchBoxCanAnimateChange = useCallback(() => {
if (!searchBoxAutoAnimate) {
const clientWidth = document.documentElement.clientWidth
if (clientWidth < 1350)
setSearchBoxCanAnimate(false)
else
setSearchBoxCanAnimate(true)
}
}, [searchBoxAutoAnimate])
useEffect(() => {
handleSearchBoxCanAnimateChange()
}, [handleSearchBoxCanAnimateChange])
useEffect(() => {
window.addEventListener('resize', handleSearchBoxCanAnimateChange)
return () => {
window.removeEventListener('resize', handleSearchBoxCanAnimateChange)
}
}, [handleSearchBoxCanAnimateChange])
return {
searchBoxCanAnimate,
}
}

@ -10,6 +10,7 @@ import { TanstackQueryIniter } from '@/context/query-client'
type MarketplaceProps = { type MarketplaceProps = {
locale: string locale: string
searchBoxAutoAnimate?: boolean
showInstallButton?: boolean showInstallButton?: boolean
shouldExclude?: boolean shouldExclude?: boolean
searchParams?: SearchParams searchParams?: SearchParams
@ -19,6 +20,7 @@ type MarketplaceProps = {
} }
const Marketplace = async ({ const Marketplace = async ({
locale, locale,
searchBoxAutoAnimate = true,
showInstallButton = true, showInstallButton = true,
shouldExclude, shouldExclude,
searchParams, searchParams,
@ -43,10 +45,14 @@ const Marketplace = async ({
> >
<Description locale={locale} /> <Description locale={locale} />
<IntersectionLine intersectionContainerId={intersectionContainerId} /> <IntersectionLine intersectionContainerId={intersectionContainerId} />
<SearchBoxWrapper locale={locale} /> <SearchBoxWrapper
locale={locale}
searchBoxAutoAnimate={searchBoxAutoAnimate}
/>
<PluginTypeSwitch <PluginTypeSwitch
locale={locale} locale={locale}
className={pluginTypeSwitchClassName} className={pluginTypeSwitchClassName}
searchBoxAutoAnimate={searchBoxAutoAnimate}
/> />
<ListWrapper <ListWrapper
locale={locale} locale={locale}

@ -8,7 +8,10 @@ import {
} from '@remixicon/react' } from '@remixicon/react'
import { PluginType } from '../types' import { PluginType } from '../types'
import { useMarketplaceContext } from './context' import { useMarketplaceContext } from './context'
import { useMixedTranslation } from './hooks' import {
useMixedTranslation,
useSearchBoxAutoAnimate,
} from './hooks'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
export const PLUGIN_TYPE_SEARCH_MAP = { export const PLUGIN_TYPE_SEARCH_MAP = {
@ -22,14 +25,17 @@ export const PLUGIN_TYPE_SEARCH_MAP = {
type PluginTypeSwitchProps = { type PluginTypeSwitchProps = {
locale?: string locale?: string
className?: string className?: string
searchBoxAutoAnimate?: boolean
} }
const PluginTypeSwitch = ({ const PluginTypeSwitch = ({
locale, locale,
className, className,
searchBoxAutoAnimate,
}: PluginTypeSwitchProps) => { }: PluginTypeSwitchProps) => {
const { t } = useMixedTranslation(locale) const { t } = useMixedTranslation(locale)
const activePluginType = useMarketplaceContext(s => s.activePluginType) const activePluginType = useMarketplaceContext(s => s.activePluginType)
const handleActivePluginTypeChange = useMarketplaceContext(s => s.handleActivePluginTypeChange) const handleActivePluginTypeChange = useMarketplaceContext(s => s.handleActivePluginTypeChange)
const { searchBoxCanAnimate } = useSearchBoxAutoAnimate(searchBoxAutoAnimate)
const options = [ const options = [
{ {
@ -66,7 +72,8 @@ const PluginTypeSwitch = ({
return ( return (
<div className={cn( <div className={cn(
'sticky top-[56px] shrink-0 flex items-center justify-center py-3 bg-background-body space-x-2 z-10', 'shrink-0 flex items-center justify-center py-3 bg-background-body space-x-2',
searchBoxCanAnimate && 'sticky top-[56px] z-10',
className, className,
)}> )}>
{ {

@ -1,14 +1,20 @@
'use client' 'use client'
import { useMarketplaceContext } from '../context' import { useMarketplaceContext } from '../context'
import { useMixedTranslation } from '../hooks' import {
useMixedTranslation,
useSearchBoxAutoAnimate,
} from '../hooks'
import SearchBox from './index' import SearchBox from './index'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
type SearchBoxWrapperProps = { type SearchBoxWrapperProps = {
locale?: string locale?: string
searchBoxAutoAnimate?: boolean
} }
const SearchBoxWrapper = ({ const SearchBoxWrapper = ({
locale, locale,
searchBoxAutoAnimate,
}: SearchBoxWrapperProps) => { }: SearchBoxWrapperProps) => {
const { t } = useMixedTranslation(locale) const { t } = useMixedTranslation(locale)
const intersected = useMarketplaceContext(v => v.intersected) const intersected = useMarketplaceContext(v => v.intersected)
@ -16,12 +22,14 @@ const SearchBoxWrapper = ({
const handleSearchPluginTextChange = useMarketplaceContext(v => v.handleSearchPluginTextChange) const handleSearchPluginTextChange = useMarketplaceContext(v => v.handleSearchPluginTextChange)
const filterPluginTags = useMarketplaceContext(v => v.filterPluginTags) const filterPluginTags = useMarketplaceContext(v => v.filterPluginTags)
const handleFilterPluginTagsChange = useMarketplaceContext(v => v.handleFilterPluginTagsChange) const handleFilterPluginTagsChange = useMarketplaceContext(v => v.handleFilterPluginTagsChange)
const { searchBoxCanAnimate } = useSearchBoxAutoAnimate(searchBoxAutoAnimate)
return ( return (
<SearchBox <SearchBox
inputClassName={cn( inputClassName={cn(
'sticky top-3 mx-auto w-[640px] shrink-0', 'mx-auto w-[640px] shrink-0 z-[0]',
!intersected && 'w-[508px] transition-[width] duration-300', searchBoxCanAnimate && 'sticky top-3 z-[11]',
!intersected && searchBoxCanAnimate && 'w-[508px] transition-[width] duration-300',
)} )}
search={searchPluginText} search={searchPluginText}
onSearchChange={handleSearchPluginTextChange} onSearchChange={handleSearchPluginTextChange}

@ -102,7 +102,7 @@ export const getMarketplaceListCondition = (pluginType: string) => {
return 'category=tool' return 'category=tool'
if (pluginType === PluginType.agent) if (pluginType === PluginType.agent)
return 'category=agent_strategy' return 'category=agent-strategy'
if (pluginType === PluginType.model) if (pluginType === PluginType.model)
return 'category=model' return 'category=model'

@ -2,7 +2,9 @@
import { useEffect, useMemo, useState } from 'react' import { useEffect, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Link from 'next/link'
import { import {
RiBookOpenLine,
RiDragDropLine, RiDragDropLine,
RiEqualizer2Line, RiEqualizer2Line,
} from '@remixicon/react' } from '@remixicon/react'
@ -158,6 +160,25 @@ const PluginPage = ({
/> />
</div> </div>
<div className='flex shrink-0 items-center gap-1'> <div className='flex shrink-0 items-center gap-1'>
{
activeTab === 'discover' && (
<>
<Link
href='https://docs.dify.ai/plugins/publish-plugins/publish-to-dify-marketplace'
target='_blank'
>
<Button
className='px-3'
variant='secondary-accent'
>
<RiBookOpenLine className='mr-1 w-4 h-4' />
{t('plugin.submitPlugin')}
</Button>
</Link>
<div className='mx-2 w-[1px] h-3.5 bg-divider-regular'></div>
</>
)
}
<PluginTasks /> <PluginTasks />
{canManagement && ( {canManagement && (
<InstallPluginDropdown <InstallPluginDropdown

@ -198,6 +198,7 @@ const translation = {
installedError: '{{errorLength}} plugins failed to install', installedError: '{{errorLength}} plugins failed to install',
clearAll: 'Clear all', clearAll: 'Clear all',
}, },
submitPlugin: 'Submit plugin',
} }
export default translation export default translation

@ -198,6 +198,7 @@ const translation = {
installedError: '{{errorLength}} 个插件安装失败', installedError: '{{errorLength}} 个插件安装失败',
clearAll: '清除所有', clearAll: '清除所有',
}, },
submitPlugin: '上传插件',
} }
export default translation export default translation

Loading…
Cancel
Save