From 46899f214856e22b8ef369b536d7ed9bd01b4f15 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sun, 15 May 2022 21:58:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E6=93=8D=E4=BD=9C=E7=9A=84=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/Panel/group/Wrapper.tsx | 25 ++++++++++++++ .../Panel/personal/ConversePanel.tsx | 16 +++++++++ web/src/plugin/common/reg.ts | 33 +++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/web/src/components/Panel/group/Wrapper.tsx b/web/src/components/Panel/group/Wrapper.tsx index f307488e..28536e1e 100644 --- a/web/src/components/Panel/group/Wrapper.tsx +++ b/web/src/components/Panel/group/Wrapper.tsx @@ -6,6 +6,11 @@ import { CommonPanelWrapper } from '../common/Wrapper'; import { usePanelWindow } from '@/hooks/usePanelWindow'; import { OpenedPanelTip } from '@/components/OpenedPanelTip'; import { IconBtn } from '@/components/IconBtn'; +import { + DMPluginPanelActionProps, + GroupPluginPanelActionProps, + pluginPanelActions, +} from '@/plugin/common'; /** * 群组面板通用包装器 @@ -41,6 +46,26 @@ export const GroupPanelWrapper: React.FC = React.memo( [ + ...pluginPanelActions + .filter( + (action): action is GroupPluginPanelActionProps => + action.position === 'group' + ) + .map((action) => ( + + action.onClick({ + groupId: props.groupId, + panelId: props.panelId, + }) + } + /> + )), = React.memo(({ converse }) => { @@ -60,6 +61,21 @@ export const ConversePanel: React.FC = React.memo( } return _compact([ + ...pluginPanelActions + .filter( + (action): action is DMPluginPanelActionProps => + action.position === 'dm' + ) + .map((action) => ( + action.onClick({ converseId })} + /> + )), (); + +export interface BasePluginPanelActionProps { + /** + * 唯一标识 + */ + name: string; + /** + * 显示名 + */ + label: string; + /** + * 来自iconify的图标标识 + */ + icon: string; +} + +export interface GroupPluginPanelActionProps + extends BasePluginPanelActionProps { + position: 'group'; + onClick: (ctx: { groupId: string; panelId: string }) => void; +} + +export interface DMPluginPanelActionProps extends BasePluginPanelActionProps { + position: 'dm'; + onClick: (ctx: { converseId: string }) => void; +} + +/** + * 注册面板操作 + */ +export const [pluginPanelActions, regPluginPanelAction] = buildRegList< + GroupPluginPanelActionProps | DMPluginPanelActionProps +>();