fix: marketplace

This commit is contained in:
StyleZhang 2024-11-07 15:37:22 +08:00
parent 65285965b6
commit b83dc5ab99
8 changed files with 28 additions and 64 deletions

View File

@ -100,6 +100,15 @@ export const MarketplaceContextProvider = ({
setSearchPluginText(text) setSearchPluginText(text)
searchPluginTextRef.current = text searchPluginTextRef.current = text
if (!searchPluginTextRef.current && !filterPluginTagsRef.current.length) {
queryMarketplaceCollectionsAndPlugins({
category: activePluginTypeRef.current === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : activePluginTypeRef.current,
})
setPlugins(undefined)
return
}
queryPluginsWithDebounced({ queryPluginsWithDebounced({
query: text, query: text,
category: activePluginTypeRef.current === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : activePluginTypeRef.current, category: activePluginTypeRef.current === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : activePluginTypeRef.current,
@ -107,12 +116,21 @@ export const MarketplaceContextProvider = ({
sortBy: sortRef.current.sortBy, sortBy: sortRef.current.sortBy,
sortOrder: sortRef.current.sortOrder, sortOrder: sortRef.current.sortOrder,
}) })
}, [queryPluginsWithDebounced]) }, [queryPluginsWithDebounced, queryMarketplaceCollectionsAndPlugins, setPlugins])
const handleFilterPluginTagsChange = useCallback((tags: string[]) => { const handleFilterPluginTagsChange = useCallback((tags: string[]) => {
setFilterPluginTags(tags) setFilterPluginTags(tags)
filterPluginTagsRef.current = tags filterPluginTagsRef.current = tags
if (!searchPluginTextRef.current && !filterPluginTagsRef.current.length) {
queryMarketplaceCollectionsAndPlugins({
category: activePluginTypeRef.current === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : activePluginTypeRef.current,
})
setPlugins(undefined)
return
}
queryPlugins({ queryPlugins({
query: searchPluginTextRef.current, query: searchPluginTextRef.current,
category: activePluginTypeRef.current === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : activePluginTypeRef.current, category: activePluginTypeRef.current === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : activePluginTypeRef.current,
@ -120,7 +138,7 @@ export const MarketplaceContextProvider = ({
sortBy: sortRef.current.sortBy, sortBy: sortRef.current.sortBy,
sortOrder: sortRef.current.sortOrder, sortOrder: sortRef.current.sortOrder,
}) })
}, [queryPlugins]) }, [queryPlugins, setPlugins, queryMarketplaceCollectionsAndPlugins])
const handleActivePluginTypeChange = useCallback((type: string) => { const handleActivePluginTypeChange = useCallback((type: string) => {
setActivePluginType(type) setActivePluginType(type)
@ -130,7 +148,7 @@ export const MarketplaceContextProvider = ({
queryMarketplaceCollectionsAndPlugins({ queryMarketplaceCollectionsAndPlugins({
category: type === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : type, category: type === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : type,
}) })
setPlugins([]) setPlugins(undefined)
return return
} }

View File

@ -14,10 +14,10 @@ const Description = async ({
return ( return (
<> <>
<h1 className='mb-2 text-center title-4xl-semi-bold text-text-primary'> <h1 className='shrink-0 mb-2 text-center title-4xl-semi-bold text-text-primary'>
Empower your AI development Empower your AI development
</h1> </h1>
<h2 className='flex justify-center items-center text-center body-md-regular text-text-tertiary'> <h2 className='shrink-0 flex justify-center items-center text-center body-md-regular text-text-tertiary'>
Discover Discover
<span className="relative ml-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected"> <span className="relative ml-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected">
{t('category.models')} {t('category.models')}

View File

@ -4,7 +4,7 @@ import Line from './line'
const Empty = () => { const Empty = () => {
return ( return (
<div <div
className='relative grid grid-cols-4 grid-rows-4 gap-3 p-2' className='grow relative h-0 grid grid-cols-4 grid-rows-4 gap-3 p-2 overflow-hidden'
> >
{ {
Array.from({ length: 16 }).map((_, index) => ( Array.from({ length: 16 }).map((_, index) => (

View File

@ -28,60 +28,6 @@ const Marketplace = async ({
marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap} marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap}
showInstallButton={showInstallButton} showInstallButton={showInstallButton}
/> />
<ListWrapper
locale={locale}
marketplaceCollections={marketplaceCollections}
marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap}
showInstallButton={showInstallButton}
/>
<ListWrapper
locale={locale}
marketplaceCollections={marketplaceCollections}
marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap}
showInstallButton={showInstallButton}
/>
<ListWrapper
locale={locale}
marketplaceCollections={marketplaceCollections}
marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap}
showInstallButton={showInstallButton}
/>
<ListWrapper
locale={locale}
marketplaceCollections={marketplaceCollections}
marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap}
showInstallButton={showInstallButton}
/>
<ListWrapper
locale={locale}
marketplaceCollections={marketplaceCollections}
marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap}
showInstallButton={showInstallButton}
/>
<ListWrapper
locale={locale}
marketplaceCollections={marketplaceCollections}
marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap}
showInstallButton={showInstallButton}
/>
<ListWrapper
locale={locale}
marketplaceCollections={marketplaceCollections}
marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap}
showInstallButton={showInstallButton}
/>
<ListWrapper
locale={locale}
marketplaceCollections={marketplaceCollections}
marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap}
showInstallButton={showInstallButton}
/>
<ListWrapper
locale={locale}
marketplaceCollections={marketplaceCollections}
marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap}
showInstallButton={showInstallButton}
/>
</MarketplaceContextProvider> </MarketplaceContextProvider>
) )
} }

View File

@ -22,7 +22,7 @@ const ListWrapper = ({
const marketplaceCollectionPluginsMapFromClient = useMarketplaceContext(v => v.marketplaceCollectionPluginsMapFromClient) const marketplaceCollectionPluginsMapFromClient = useMarketplaceContext(v => v.marketplaceCollectionPluginsMapFromClient)
return ( return (
<div className='px-12 py-2 bg-background-default-subtle'> <div className='flex flex-col grow px-12 py-2 bg-background-default-subtle'>
{ {
plugins && ( plugins && (
<div className='flex items-center mb-4 pt-3'> <div className='flex items-center mb-4 pt-3'>

View File

@ -57,7 +57,7 @@ const PluginTypeSwitch = ({
return ( return (
<div className={cn( <div className={cn(
'sticky top-[60px] flex items-center justify-center py-3 bg-background-body space-x-2 z-10', 'sticky top-[60px] shrink-0 flex items-center justify-center py-3 bg-background-body space-x-2 z-10',
)}> )}>
{ {
options.map(option => ( options.map(option => (

View File

@ -41,7 +41,7 @@ const SearchBox = ({
/> />
<div className='mx-1 w-[1px] h-3.5 bg-divider-regular'></div> <div className='mx-1 w-[1px] h-3.5 bg-divider-regular'></div>
<div className='grow flex items-center p-1 pl-2'> <div className='grow flex items-center p-1 pl-2'>
<div className='flex items-center mr-2 py-0.5 w-full'> <div className='flex items-center mr-2 w-full'>
<input <input
className={cn( className={cn(
'grow block outline-none appearance-none body-md-medium text-text-secondary bg-transparent', 'grow block outline-none appearance-none body-md-medium text-text-secondary bg-transparent',

View File

@ -20,7 +20,7 @@ const SearchBoxWrapper = ({
return ( return (
<SearchBox <SearchBox
inputClassName={cn( inputClassName={cn(
'sticky top-3 mx-auto w-[640px]', 'sticky top-3 mx-auto w-[640px] shrink-0',
!intersected && 'w-[508px] transition-[width] duration-300', !intersected && 'w-[508px] transition-[width] duration-300',
)} )}
search={searchPluginText} search={searchPluginText}