diff --git a/web/src/routes/Main/Content/Group/SidebarItem.tsx b/web/src/routes/Main/Content/Group/SidebarItem.tsx index f10ec2a4..a20d2e20 100644 --- a/web/src/routes/Main/Content/Group/SidebarItem.tsx +++ b/web/src/routes/Main/Content/Group/SidebarItem.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import { groupActions, GroupPanel, @@ -16,26 +16,9 @@ import { Dropdown, Menu } from 'antd'; import copy from 'copy-to-clipboard'; import { usePanelWindow } from '@/hooks/usePanelWindow'; import { LoadingSpinner } from '@/components/LoadingSpinner'; +import _compact from 'lodash/compact'; import { Icon } from '@/components/Icon'; -const GroupAckMenuItem: React.FC<{ - panelId: string; -}> = (props) => { - const { markConverseAllAck } = useConverseAck(props.panelId); - - return ( - } - onClick={() => { - markConverseAllAck(); - }} - > - {t('标记为已读')} - - ); -}; -GroupAckMenuItem.displayName = 'GroupAckMenuItem'; - /** * 群组面板侧边栏组件 */ @@ -49,6 +32,7 @@ export const SidebarItem: React.FC<{ ); const groupInfo = useGroupInfo(groupId); const dispatch = useAppDispatch(); + const { markConverseAllAck } = useConverseAck(panel.id); if (!groupInfo) { return ; @@ -58,58 +42,58 @@ export const SidebarItem: React.FC<{ isValidStr(groupInfo.pinnedPanelId) && groupInfo.pinnedPanelId === panel.id; const menu = ( - - } - onClick={() => { - copy(`${location.origin}/main/group/${groupId}/${panel.id}`); - showToasts(t('已复制到剪切板')); - }} - > - {t('复制链接')} - - - } - disabled={hasOpenedPanel} - onClick={openPanelWindow} - > - {t('在新窗口打开')} - - - {isPinned ? ( - } - onClick={() => { - dispatch( - groupActions.unpinGroupPanel({ - groupId, - }) - ); - }} - > - {t('Unpin')} - - ) : ( - } - onClick={() => { - dispatch( - groupActions.pinGroupPanel({ - groupId, - panelId: panel.id, - }) - ); - }} - > - {t('Pin')} - - )} - - {panel.type === GroupPanelType.TEXT && ( - - )} - + , + onClick: () => { + copy(`${location.origin}/main/group/${groupId}/${panel.id}`); + showToasts(t('已复制到剪切板')); + }, + }, + { + key: 'new', + label: t('在新窗口打开'), + icon: , + disabled: hasOpenedPanel, + onClick: openPanelWindow, + }, + isPinned + ? { + key: 'unpin', + label: t('Unpin'), + icon: , + onClick: () => { + dispatch( + groupActions.unpinGroupPanel({ + groupId, + }) + ); + }, + } + : { + key: 'pin', + label: t('Pin'), + icon: , + onClick: () => { + dispatch( + groupActions.pinGroupPanel({ + groupId, + panelId: panel.id, + }) + ); + }, + }, + panel.type === GroupPanelType.TEXT && { + key: 'copy', + label: t('标记为已读'), + icon: , + onClick: markConverseAllAck, + }, + ])} + /> ); const icon = isPinned ? : ;