mirror of https://github.com/msgbyte/tailchat
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
4 years ago
|
/**
|
||
|
* 插件商店
|
||
|
*/
|
||
|
|
||
|
import { LoadingSpinner } from '@/components/LoadingSpinner';
|
||
|
import { Divider } from 'antd';
|
||
|
import React from 'react';
|
||
|
import { t, useAsync } from 'tailchat-shared';
|
||
|
import { builtinPlugins } from '../builtin';
|
||
|
import { pluginManager } from '../manager';
|
||
|
import { PluginStoreItem } from './Item';
|
||
|
|
||
|
export const PluginStore: React.FC = React.memo(() => {
|
||
|
const { loading, value: installedPluginNameList = [] } =
|
||
|
useAsync(async () => {
|
||
|
const plugins = await pluginManager.getInstalledPlugins();
|
||
|
return plugins.map((p) => p.name);
|
||
|
}, []);
|
||
|
|
||
|
if (loading) {
|
||
|
return <LoadingSpinner tip={t('正在加载已安装插件')} />;
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<div className="p-2 w-full">
|
||
|
{/* 内置插件 */}
|
||
|
<Divider orientation="left">{t('内置插件')}</Divider>
|
||
|
|
||
|
<div>
|
||
|
{builtinPlugins.map((plugin) => (
|
||
|
<PluginStoreItem
|
||
|
key={plugin.name}
|
||
|
manifest={plugin}
|
||
|
installed={installedPluginNameList.includes(plugin.name)}
|
||
|
builtin={true}
|
||
|
/>
|
||
|
))}
|
||
|
</div>
|
||
|
|
||
|
<Divider orientation="left">{t('插件中心')}</Divider>
|
||
|
</div>
|
||
|
);
|
||
|
});
|
||
|
PluginStore.displayName = 'PluginStore';
|