-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: support OpenAPI Authentication
- Loading branch information
1 parent
11a39b1
commit 820c15e
Showing
10 changed files
with
656 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,85 @@ | ||
import { LobeChatPluginMeta } from '@lobehub/chat-plugin-sdk'; | ||
import { Avatar, Icon, Tag } from '@lobehub/ui'; | ||
import { Avatar, Tag } from '@lobehub/ui'; | ||
import { Button } from 'antd'; | ||
import { createStyles, useResponsive } from 'antd-style'; | ||
import { BadgeCheck, CircleUser } from 'lucide-react'; | ||
import { createStyles } from 'antd-style'; | ||
import Link from 'next/link'; | ||
import { memo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { Flexbox } from 'react-layout-kit'; | ||
|
||
import { useToolStore } from '@/store/tool'; | ||
import { pluginSelectors, pluginStoreSelectors } from '@/store/tool/selectors'; | ||
import { InstallPluginMeta } from '@/types/tool/plugin'; | ||
|
||
import PluginSettings from './PluginSettings'; | ||
|
||
const useStyles = createStyles(({ css, token }) => ({ | ||
desc: css` | ||
color: ${token.colorTextDescription}; | ||
color: ${token.colorTextSecondary}; | ||
`, | ||
link: css` | ||
color: ${token.colorText}; | ||
color: ${token.colorTextDescription}; | ||
`, | ||
tag: css` | ||
color: ${token.colorTextSecondary}; | ||
font-weight: normal; | ||
`, | ||
title: css` | ||
font-size: ${token.fontSizeLG}px; | ||
font-weight: bold; | ||
line-height: 2; | ||
`, | ||
})); | ||
const PluginItem = memo<LobeChatPluginMeta>(({ identifier, homepage, author, meta }) => { | ||
const [installed, installing, installPlugin, unInstallPlugin] = useToolStore((s) => [ | ||
pluginSelectors.isPluginInstalled(identifier)(s), | ||
pluginStoreSelectors.isPluginInstallLoading(identifier)(s), | ||
s.installPlugin, | ||
s.uninstallPlugin, | ||
]); | ||
const { mobile } = useResponsive(); | ||
const { styles } = useStyles(); | ||
|
||
const { t } = useTranslation('plugin'); | ||
return ( | ||
<Flexbox align={'center'} gap={8} horizontal justify={'space-between'}> | ||
<Flexbox align={'center'} gap={8} horizontal> | ||
<Avatar avatar={meta.avatar} size={mobile ? 40 : 56} style={{ flex: 'none' }} /> | ||
<Flexbox gap={4}> | ||
<Flexbox align={'center'} gap={8} horizontal> | ||
<Link className={styles.link} href={homepage} target={'_blank'}> | ||
<div className={styles.title}>{meta.title}</div> | ||
</Link> | ||
const PluginItem = memo<InstallPluginMeta>( | ||
({ identifier, createdAt, homepage, author, type, meta = {} }) => { | ||
console.log(type); | ||
const [installed, installing, installPlugin, unInstallPlugin] = useToolStore((s) => [ | ||
pluginSelectors.isPluginInstalled(identifier)(s), | ||
pluginStoreSelectors.isPluginInstallLoading(identifier)(s), | ||
s.installPlugin, | ||
s.uninstallPlugin, | ||
]); | ||
const { styles } = useStyles(); | ||
|
||
const { t } = useTranslation('plugin'); | ||
return ( | ||
<Flexbox gap={8} padding={16}> | ||
<Flexbox horizontal justify={'space-between'}> | ||
<Avatar avatar={meta.avatar} size={56} style={{ flex: 'none' }} /> | ||
|
||
<Tag | ||
className={styles.tag} | ||
icon={<Icon icon={author === 'LobeHub' ? BadgeCheck : CircleUser} />} | ||
<Flexbox gap={8} horizontal> | ||
<PluginSettings identifier={identifier} /> | ||
<Button | ||
loading={installing} | ||
onClick={() => { | ||
if (installed) { | ||
unInstallPlugin(identifier); | ||
} else installPlugin(identifier); | ||
}} | ||
type={installed ? 'default' : 'primary'} | ||
> | ||
{author} | ||
</Tag> | ||
{t(installed ? 'store.uninstall' : 'store.install')} | ||
</Button> | ||
</Flexbox> | ||
</Flexbox> | ||
|
||
<Flexbox gap={4}> | ||
<Flexbox align={'center'} gap={8} horizontal> | ||
<div className={styles.title}>{meta.title}</div> | ||
<Tag className={styles.tag}> {identifier}</Tag> | ||
</Flexbox> | ||
<div className={styles.desc}>{meta.description}</div> | ||
<Flexbox className={styles.link} gap={8} horizontal> | ||
{author && ( | ||
<Link className={styles.link} href={homepage ?? ''} target={'_blank'}> | ||
@{author} | ||
</Link> | ||
)} | ||
{createdAt && t('store.releasedAt', { createdAt })} | ||
</Flexbox> | ||
<div className={styles.desc}>{meta.description} </div> | ||
</Flexbox> | ||
</Flexbox> | ||
<Flexbox align={'center'} gap={8} horizontal> | ||
<PluginSettings identifier={identifier} /> | ||
<Button | ||
loading={installing} | ||
onClick={() => { | ||
if (installed) { | ||
unInstallPlugin(identifier); | ||
} else installPlugin(identifier); | ||
}} | ||
size={mobile ? 'small' : undefined} | ||
type={installed ? 'default' : 'primary'} | ||
> | ||
{t(installed ? 'store.uninstall' : 'store.install')} | ||
</Button> | ||
</Flexbox> | ||
</Flexbox> | ||
); | ||
}); | ||
); | ||
}, | ||
); | ||
|
||
export default PluginItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.