diff --git a/web/src/components/modals/SettingsView/index.tsx b/web/src/components/modals/SettingsView/index.tsx index bd6f7d4e..02f1f368 100644 --- a/web/src/components/modals/SettingsView/index.tsx +++ b/web/src/components/modals/SettingsView/index.tsx @@ -1,5 +1,10 @@ import { FullModal } from '@/components/FullModal'; -import { SidebarView, SidebarViewMenuType } from '@/components/SidebarView'; +import { + SidebarView, + SidebarViewMenuItem, + SidebarViewMenuType, +} from '@/components/SidebarView'; +import { pluginCustomPanel } from '@/plugin/common'; import React, { useCallback, useMemo } from 'react'; import { t } from 'tailchat-shared'; import { SettingsAbout } from './About'; @@ -21,42 +26,57 @@ export const SettingsView: React.FC = React.memo((props) => { [props.onClose] ); - const menu: SidebarViewMenuType[] = useMemo( - () => [ - { + const menu: SidebarViewMenuType[] = useMemo(() => { + const common: SidebarViewMenuType = { + type: 'group', + title: t('通用'), + children: [ + { + type: 'item', + title: t('账户信息'), + content: , + }, + { + type: 'item', + title: t('系统设置'), + content: , + }, + { + type: 'item', + title: t('服务状态'), + content: , + }, + { + type: 'item', + title: t('性能统计'), + content: , + }, + { + type: 'item', + title: t('关于'), + content: , + }, + ], + }; + const more: SidebarViewMenuItem[] = pluginCustomPanel + .filter((p) => p.position === 'setting') + .map((p) => ({ + type: 'item', + title: p.label, + content: React.createElement(p.render), + })); + + const menu: SidebarViewMenuType[] = [common]; + if (more.length > 0) { + menu.push({ type: 'group', - title: t('通用'), - children: [ - { - type: 'item', - title: t('账户信息'), - content: , - }, - { - type: 'item', - title: t('系统设置'), - content: , - }, - { - type: 'item', - title: t('服务状态'), - content: , - }, - { - type: 'item', - title: t('性能统计'), - content: , - }, - { - type: 'item', - title: t('关于'), - content: , - }, - ], - }, - ], - [] - ); + title: t('更多'), + children: [...more], + }); + } + + return menu; + }, []); return ( diff --git a/web/src/plugin/common/reg.ts b/web/src/plugin/common/reg.ts index 5e64d1f9..44d1ea5b 100644 --- a/web/src/plugin/common/reg.ts +++ b/web/src/plugin/common/reg.ts @@ -14,9 +14,10 @@ export interface PluginCustomPanel { * 面板位置: * * - personal: 个人面板中的一项 + * - setting: 设置面板 * - navbar: 导航栏(未实装) */ - position: 'personal' | 'navbar'; + position: 'personal' | 'setting' | 'navbar'; /** * Iconify 名