Skip to content

Commit b129cd7

Browse files
committed
fix: add plugin list maybe repeat problem
1 parent ae33aa3 commit b129cd7

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

client/web/src/plugin/PluginStore/index.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { builtinPlugins } from '../builtin';
1111
import { pluginManager } from '../manager';
1212
import { PluginStoreItem } from './Item';
1313
import { ManualInstall } from './ManualInstall';
14+
import _uniqBy from 'lodash/uniqBy';
1415

1516
function usePluginStoreData() {
1617
const { loading: loading1, value: installedPluginList = [] } = useAsync(
@@ -48,14 +49,16 @@ export const PluginStore: React.FC = React.memo(() => {
4849
<Divider orientation="left">{t('已安装')}</Divider>
4950

5051
<div className="flex flex-wrap">
51-
{[...builtinPlugins, ...installedPluginList].map((plugin) => (
52-
<PluginStoreItem
53-
key={plugin.name}
54-
manifest={plugin}
55-
installed={true}
56-
builtin={builtinPluginNameList.includes(plugin.name)}
57-
/>
58-
))}
52+
{_uniqBy([...builtinPlugins, ...installedPluginList], 'name').map(
53+
(plugin) => (
54+
<PluginStoreItem
55+
key={plugin.name}
56+
manifest={plugin}
57+
installed={true}
58+
builtin={builtinPluginNameList.includes(plugin.name)}
59+
/>
60+
)
61+
)}
5962
</div>
6063
</PillTabPane>
6164

client/web/src/plugin/manager.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import _once from 'lodash/once';
99
import { builtinPlugins } from './builtin';
1010
import { showPluginLoadError } from './showPluginLoadError';
1111
import { injectTailchatGlobalValue } from '@/utils/global-helper';
12+
import _uniqBy from 'lodash/uniqBy';
1213

1314
class PluginManager {
1415
/**
@@ -20,10 +21,10 @@ class PluginManager {
2021
* 初始化插件
2122
*/
2223
initPlugins = _once(async () => {
23-
const installedPlugins = [
24-
...builtinPlugins,
25-
...(await this.getInstalledPlugins()),
26-
];
24+
const installedPlugins = _uniqBy(
25+
[...builtinPlugins, ...(await this.getInstalledPlugins())],
26+
'name'
27+
);
2728

2829
const plugins = installedPlugins.map(({ name, url }) => ({
2930
name,

0 commit comments

Comments
 (0)