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 +>();