feat: 增加个人面板自定义面板

pull/81/head
moonrailgun 3 years ago
parent d7b6e8ca50
commit 7e431b1972

@ -61,7 +61,7 @@ export const t: TFunction = (
/**
*
* @example
* localTrans({zh-CN: '你好', en-US: 'Hello'});
* localTrans({'zh-CN': '你好', 'en-US': 'Hello'});
*
* @param trans
*/

@ -9,6 +9,7 @@ export {
useCurrentGroupPanelInfo,
} from '@/routes/Main/Content/Group/utils';
export { openModal, ModalWrapper, useModalContext } from '@/components/Modal';
export { Loadable } from '@/components/Loadable';
export { getGlobalState } from '@/utils/global-state-helper';
export {
getCachedUserInfo,

@ -6,6 +6,41 @@ import {
regSocketEventListener,
} from 'tailchat-shared';
/**
*
*/
export interface PluginCustomPanel {
/**
* :
*
* - personal:
* - navbar: ()
*/
position: 'personal' | 'navbar';
/**
* Iconify
*/
icon: string;
/**
*
*/
name: string;
/**
*
*/
label: string;
/**
*
*/
render: React.ComponentType;
}
export const [pluginCustomPanel, regCustomPanel] =
buildRegList<PluginCustomPanel>();
/**
*
*/

@ -8,6 +8,7 @@ import { CreateDMConverse } from '@/components/modals/CreateDMConverse';
import { DevContainer } from '@/components/DevContainer';
import { SectionHeader } from '@/components/SectionHeader';
import { CommonSidebarWrapper } from '@/components/CommonSidebarWrapper';
import { pluginCustomPanel } from '@/plugin/common';
const SidebarSection: React.FC<{
action: React.ReactNode;
@ -47,6 +48,19 @@ export const PersonalSidebar: React.FC = React.memo(() => {
icon={<Icon icon="mdi:puzzle" />}
to="/main/personal/plugins"
/>
{/* 插件自定义面板 */}
{pluginCustomPanel
.filter((p) => p.position === 'personal')
.map((p) => (
<SidebarItem
key={p.name}
name={p.label}
icon={<Icon icon={p.icon} />}
to={`/main/personal/custom/${p.name}`}
/>
))}
<SidebarSection
action={
<DevContainer>

@ -1,3 +1,4 @@
import { pluginCustomPanel } from '@/plugin/common';
import React from 'react';
import { Redirect, Route, Switch } from 'react-router-dom';
import { PageContent } from '../PageContent';
@ -19,6 +20,16 @@ export const Personal: React.FC = React.memo(() => {
component={PersonalConverse}
/>
{pluginCustomPanel
.filter((p) => p.position === 'personal')
.map((p) => (
<Route
key={p.name}
path={`/main/personal/custom/${p.name}`}
component={p.render}
/>
))}
<Redirect to="/main/personal/friends" />
</Switch>
</PageContent>

Loading…
Cancel
Save