mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
🐛 fix: Showing compatibility with both new and old versions of Plugins (#10418)
* fix: Showing compatibility with both new and old versions of Plugins * fix: add mcp plugin detail as plugins return
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Block } from '@lobehub/ui';
|
||||
import { Empty } from 'antd';
|
||||
import Link from 'next/link';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { memo } from 'react';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
import urlJoin from 'url-join';
|
||||
@@ -20,11 +20,16 @@ const Plugin = memo(() => {
|
||||
|
||||
return (
|
||||
<Flexbox gap={8}>
|
||||
{config?.plugins.map((item) => (
|
||||
<Link href={urlJoin('/discover/plugin', item)} key={item}>
|
||||
<PluginItem identifier={item} />
|
||||
</Link>
|
||||
))}
|
||||
{config?.plugins.map((item) => {
|
||||
const identifier =
|
||||
typeof item === 'string' ? item : (item as { identifier: string }).identifier;
|
||||
|
||||
return (
|
||||
<Link key={identifier} to={urlJoin('/discover/plugin', identifier)}>
|
||||
<PluginItem identifier={identifier} />
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</Flexbox>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -886,8 +886,48 @@ export class DiscoverService {
|
||||
const all = await this._getPluginList(locale);
|
||||
let raw = all.find((item) => item.identifier === identifier);
|
||||
if (!raw) {
|
||||
log('getPluginDetail: plugin not found for identifier=%s', identifier);
|
||||
return;
|
||||
log('getPluginDetail: plugin not found in default store for identifier=%s, trying MCP plugin', identifier);
|
||||
try {
|
||||
const mcpDetail = await this.getMcpDetail({ identifier, locale });
|
||||
const convertedMcp: Partial<DiscoverPluginDetail> = {
|
||||
author:
|
||||
typeof (mcpDetail as any).author === 'object'
|
||||
? (mcpDetail as any).author?.name || ''
|
||||
: (mcpDetail as any).author || '',
|
||||
avatar: (mcpDetail as any).icon || (mcpDetail as any).avatar || '',
|
||||
category: (mcpDetail as any).category as any,
|
||||
createdAt: (mcpDetail as any).createdAt || '',
|
||||
description: mcpDetail.description || '',
|
||||
homepage: mcpDetail.homepage || '',
|
||||
identifier: mcpDetail.identifier,
|
||||
manifest: undefined,
|
||||
related: mcpDetail.related.map((item) => ({
|
||||
author:
|
||||
typeof (item as any).author === 'object'
|
||||
? (item as any).author?.name || ''
|
||||
: (item as any).author || '',
|
||||
avatar: (item as any).icon || (item as any).avatar || '',
|
||||
category: (item as any).category as any,
|
||||
createdAt: (item as any).createdAt || '',
|
||||
description: (item as any).description || '',
|
||||
homepage: (item as any).homepage || '',
|
||||
identifier: item.identifier,
|
||||
manifest: undefined,
|
||||
schemaVersion: 1,
|
||||
tags: (item as any).tags || [],
|
||||
title: (item as any).name || item.identifier,
|
||||
})) as unknown as DiscoverPluginItem[],
|
||||
schemaVersion: 1,
|
||||
tags: (mcpDetail as any).tags || [],
|
||||
title: (mcpDetail as any).name || mcpDetail.identifier,
|
||||
};
|
||||
const plugin = merge(cloneDeep(DEFAULT_DISCOVER_PLUGIN_ITEM), convertedMcp);
|
||||
log('getPluginDetail: returning converted MCP plugin');
|
||||
return plugin as DiscoverPluginDetail;
|
||||
} catch (error) {
|
||||
log('getPluginDetail: MCP plugin not found for identifier=%s, error=%O', identifier, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
raw = merge(cloneDeep(DEFAULT_DISCOVER_PLUGIN_ITEM), raw);
|
||||
|
||||
Reference in New Issue
Block a user