Skip to content

Commit 522fc09

Browse files
🐛 fix(plugin-store): fix search functionality for old plugin store (lobehub#9651)
- Update Search component to handle different search keywords based on current tab (MCP vs Plugin) - Add missing useEffect in Plugin List to reset list when search keywords change - Fixes issue where typing in search bar didn't trigger plugin filtering Fixes lobehub#9645 Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Shinji-Li <[email protected]>
1 parent 72fcc7a commit 522fc09

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/features/PluginStore/PluginList/List/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Icon } from '@lobehub/ui';
22
import { Empty } from 'antd';
33
import { ServerCrash } from 'lucide-react';
4-
import { memo } from 'react';
4+
import { memo, useEffect } from 'react';
55
import { useTranslation } from 'react-i18next';
66
import { Center, Flexbox } from 'react-layout-kit';
77
import { Virtuoso } from 'react-virtuoso';
@@ -25,6 +25,7 @@ export const List = memo(() => {
2525
searchLoading,
2626
useFetchPluginList,
2727
loadMorePlugins,
28+
resetPluginList,
2829
] = useToolStore((s) => [
2930
s.isPluginListInit,
3031
s.activePluginIdentifier,
@@ -35,8 +36,14 @@ export const List = memo(() => {
3536
s.pluginSearchLoading,
3637
s.useFetchPluginList,
3738
s.loadMorePlugins,
39+
s.resetPluginList,
3840
]);
3941

42+
// 当 keywords 变化时重置列表
43+
useEffect(() => {
44+
resetPluginList(keywords);
45+
}, [keywords, resetPluginList]);
46+
4047
const { isLoading, error } = useFetchPluginList({
4148
page: currentPage,
4249
pageSize: 20,

src/features/PluginStore/Search/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ import { useTranslation } from 'react-i18next';
44
import { Flexbox } from 'react-layout-kit';
55

66
import { useToolStore } from '@/store/tool';
7+
import { PluginStoreTabs } from '@/store/tool/slices/oldStore';
78

89
export const Search = memo(() => {
910
const { t } = useTranslation('plugin');
10-
const [keywords] = useToolStore((s) => [s.mcpSearchKeywords]);
11+
const [listType, mcpKeywords, pluginKeywords] = useToolStore((s) => [
12+
s.listType,
13+
s.mcpSearchKeywords,
14+
s.pluginSearchKeywords,
15+
]);
16+
17+
// 根据当前选项卡决定使用哪个关键词
18+
const keywords = listType === PluginStoreTabs.MCP ? mcpKeywords : pluginKeywords;
1119

1220
return (
1321
<Flexbox align={'center'} gap={8} horizontal justify={'space-between'}>
@@ -16,7 +24,11 @@ export const Search = memo(() => {
1624
allowClear
1725
defaultValue={keywords}
1826
onSearch={(keywords: string) => {
19-
useToolStore.setState({ mcpSearchKeywords: keywords, searchLoading: true });
27+
if (listType === PluginStoreTabs.MCP) {
28+
useToolStore.setState({ mcpSearchKeywords: keywords, searchLoading: true });
29+
} else if (listType === PluginStoreTabs.Plugin) {
30+
useToolStore.setState({ pluginSearchKeywords: keywords, pluginSearchLoading: true });
31+
}
2032
}}
2133
placeholder={t('store.placeholder')}
2234
variant={'borderless'}

0 commit comments

Comments
 (0)