feat: enhance plugin filtering with tags support

This commit is contained in:
twwu 2024-11-06 16:18:18 +08:00
parent 4cf9ff6132
commit cce39b85e9
3 changed files with 4 additions and 4 deletions

View File

@ -21,7 +21,6 @@ import Title from '../card/base/title'
import Action from './action'
import cn from '@/utils/classnames'
import I18n from '@/context/i18n'
import { API_PREFIX, MARKETPLACE_URL_PREFIX } from '@/config'
type Props = {

View File

@ -10,7 +10,7 @@ import { useDebounceFn } from 'ahooks'
import Empty from './empty'
const PluginsPanel = () => {
const [filters, setFilters] = usePluginPageContext(v => [v.filters, v.setFilters])
const [filters, setFilters] = usePluginPageContext(v => [v.filters, v.setFilters]) as [FilterState, (filter: FilterState) => void]
const pluginList = usePluginPageContext(v => v.installedPluginList) as PluginDetail[]
const mutateInstalledPluginList = usePluginPageContext(v => v.mutateInstalledPluginList)
@ -19,11 +19,11 @@ const PluginsPanel = () => {
}, { wait: 500 })
const filteredList = useMemo(() => {
// todo: filter by tags
const { categories, searchQuery } = filters
const { categories, searchQuery, tags } = filters
const filteredList = pluginList.filter((plugin) => {
return (
(categories.length === 0 || categories.includes(plugin.declaration.category))
&& (tags.length === 0 || tags.some(tag => plugin.declaration.tags.includes(tag)))
&& (searchQuery === '' || plugin.plugin_id.toLowerCase().includes(searchQuery.toLowerCase()))
)
})

View File

@ -69,6 +69,7 @@ export type PluginDeclaration = {
endpoint: PluginEndpointDeclaration
tool: PluginToolDeclaration
model: any // TODO
tags: string[]
}
export type PluginManifestInMarket = {