import { Avatar } from '@/components/Avatar'; import { Button } from 'antd'; import React, { useState } from 'react'; import { PluginManifest, showToasts, t, useAsyncRequest, } from 'tailchat-shared'; import { pluginManager } from '../manager'; /** * 插件项 */ export const PluginStoreItem: React.FC<{ manifest: PluginManifest; installed: boolean; builtin: boolean; }> = React.memo((props) => { const { manifest, builtin } = props; const [installed, setInstalled] = useState(props.installed); const [{ loading }, handleInstallPlugin] = useAsyncRequest(async () => { await pluginManager.installPlugin(manifest); if (manifest.requireRestart === true) { showToasts(t('插件安装成功, 需要重启后生效'), 'success'); } else { showToasts(t('插件安装成功'), 'success'); } setInstalled(true); }, [manifest]); return (
{manifest.label}
{manifest.name}
{manifest.description}
{builtin ? ( ) : installed ? ( ) : ( )}
); }); PluginStoreItem.displayName = 'PluginStoreItem';