Skip to content

Commit a0603a9

Browse files
committed
✨ feat: add plugin market Setting Modal
1 parent 0e35c18 commit a0603a9

File tree

5 files changed

+116
-57
lines changed

5 files changed

+116
-57
lines changed

src/features/AgentSetting/AgentPlugin/MarketList.tsx

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Avatar, Form, Icon, Tooltip } from '@lobehub/ui';
2-
import { Button, Skeleton, Switch, Tag } from 'antd';
2+
import { Button, Skeleton, Space, Switch, Tag } from 'antd';
33
import { createStyles } from 'antd-style';
44
import isEqual from 'fast-deep-equal';
5-
import { LucideBlocks, LucideStore, LucideTrash2 } from 'lucide-react';
5+
import { LucideBlocks, LucideSettings, LucideStore, LucideTrash2 } from 'lucide-react';
66
import { memo, useState } from 'react';
77
import { useTranslation } from 'react-i18next';
88
import { Flexbox } from 'react-layout-kit';
@@ -13,6 +13,7 @@ import { pluginHelpers, pluginSelectors, usePluginStore } from '@/store/plugin';
1313

1414
import { useStore } from '../store';
1515
import LocalPluginItem from './LocalPluginItem';
16+
import MarketSettingModal from './MarketSettingModal';
1617

1718
const useStyles = createStyles(({ css }) => ({
1819
avatar: css`
@@ -36,6 +37,7 @@ const MarketList = memo(() => {
3637
const { styles } = useStyles();
3738

3839
const [showModal, setModal] = useState(false);
40+
const [showSettings, setShowSettings] = useState(false);
3941

4042
const [userEnabledPlugins, hasPlugin, toggleAgentPlugin] = useStore((s) => [
4143
s.config.plugins || [],
@@ -173,12 +175,13 @@ const MarketList = memo(() => {
173175
onValueChange={updateNewDevPlugin}
174176
open={showModal}
175177
/>
178+
<MarketSettingModal onOpenChange={setShowSettings} open={showSettings} />
176179
<Form
177180
items={[
178181
{
179182
children: isEmpty ? loadingList : [...deprecatedList, ...customList, ...list],
180183
extra: (
181-
<Flexbox gap={8} horizontal>
184+
<Flexbox align={'center'} gap={8} horizontal>
182185
{hasDeprecated ? (
183186
<Tooltip title={t('settingPlugin.clearDeprecated')}>
184187
<Button
@@ -191,21 +194,32 @@ const MarketList = memo(() => {
191194
}}
192195
size={'small'}
193196
type={'text'}
194-
></Button>
197+
/>
195198
</Tooltip>
196199
) : null}
197-
<Tooltip title={t('settingPlugin.addTooltip')}>
198-
<Button
199-
icon={<Icon icon={LucideBlocks} />}
200-
onClick={(e) => {
201-
e.stopPropagation();
202-
setModal(true);
203-
}}
204-
size={'small'}
205-
>
206-
{t('settingPlugin.add')}
207-
</Button>
208-
</Tooltip>
200+
201+
<Space.Compact style={{ width: 'auto' }}>
202+
<Tooltip title={t('settingPlugin.addTooltip')}>
203+
<Button
204+
icon={<Icon icon={LucideBlocks} />}
205+
onClick={(e) => {
206+
e.stopPropagation();
207+
setModal(true);
208+
}}
209+
size={'small'}
210+
/>
211+
</Tooltip>
212+
<Tooltip title={t('settingPlugin.settings')}>
213+
<Button
214+
icon={<Icon icon={LucideSettings} />}
215+
onClick={(e) => {
216+
e.stopPropagation();
217+
setShowSettings(true);
218+
}}
219+
size={'small'}
220+
/>
221+
</Tooltip>
222+
</Space.Compact>
209223
</Flexbox>
210224
),
211225
icon: LucideStore,
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { Icon, Input, Tooltip } from '@lobehub/ui';
2+
import { ConfigProvider, Form, Modal } from 'antd';
3+
import { createStyles } from 'antd-style';
4+
import { LucideSettings } from 'lucide-react';
5+
import { lighten } from 'polished';
6+
import { memo } from 'react';
7+
import { useTranslation } from 'react-i18next';
8+
import { Flexbox } from 'react-layout-kit';
9+
10+
import { PLUGINS_INDEX_URL } from '@/const/url';
11+
12+
const useStyles = createStyles(({ css, token, prefixCls }) => ({
13+
content: css`
14+
.${prefixCls}-modal-content {
15+
border: 1px solid ${token.colorSplit};
16+
border-radius: 12px;
17+
}
18+
`,
19+
root: css`
20+
backdrop-filter: blur(2px);
21+
`,
22+
}));
23+
24+
interface MarketSettingModalProps {
25+
onOpenChange: (open: boolean) => void;
26+
open?: boolean;
27+
}
28+
29+
const MarketSettingModal = memo<MarketSettingModalProps>(({ open, onOpenChange }) => {
30+
const { t } = useTranslation('plugin');
31+
const { styles, theme } = useStyles();
32+
33+
return (
34+
<ConfigProvider
35+
theme={{
36+
token: {
37+
colorBgElevated: lighten(0.005, theme.colorBgContainer),
38+
},
39+
}}
40+
>
41+
<Modal
42+
centered
43+
closable
44+
maskClosable
45+
onCancel={() => {
46+
onOpenChange(false);
47+
}}
48+
open={open}
49+
title={
50+
<Flexbox gap={8} horizontal style={{ marginBottom: 24 }}>
51+
<Icon icon={LucideSettings} />
52+
{t('settings.title')}
53+
</Flexbox>
54+
}
55+
width={700}
56+
wrapClassName={styles.root}
57+
>
58+
<Flexbox gap={12}>
59+
<Form layout={'vertical'}>
60+
<Form.Item extra={t('settings.modalDesc')} label={t('settings.indexUrl.title')}>
61+
<Tooltip title={t('settings.indexUrl.tooltip')}>
62+
<Input
63+
defaultValue={PLUGINS_INDEX_URL}
64+
disabled
65+
placeholder={'https://xxxxx.com/index.json'}
66+
/>
67+
</Tooltip>
68+
</Form.Item>
69+
</Form>
70+
</Flexbox>
71+
</Modal>
72+
</ConfigProvider>
73+
);
74+
});
75+
76+
export default MarketSettingModal;

src/features/AgentSetting/test.json

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/locales/default/plugin.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,21 @@ export default {
8787
'local.title': '自定义',
8888
},
8989
},
90-
9190
loading: {
9291
content: '数据获取中...',
9392
plugin: '插件运行中...',
9493
},
94+
9595
pluginList: '插件列表',
9696
plugins: {
9797
unknown: '插件检测中...',
9898
},
99+
settings: {
100+
indexUrl: {
101+
title: '市场索引',
102+
tooltip: '暂不支持编辑',
103+
},
104+
modalDesc: '配置插件市场的地址后,可以使用自定义的插件市场',
105+
title: '设置插件市场',
106+
},
99107
};

src/locales/default/setting.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export default {
132132
addTooltip: '添加自定义插件',
133133
clearDeprecated: '移除无效插件',
134134
config: '{{id}} 插件配置',
135+
settings: '配置插件市场',
135136
title: '插件列表',
136137
},
137138
settingSystem: {

0 commit comments

Comments
 (0)