mirror of https://github.com/msgbyte/tailchat
refactor: 群组侧边栏header
parent
a56dc48660
commit
83a73f9c21
@ -0,0 +1,36 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { Dropdown } from 'antd';
|
||||||
|
import { Icon } from '@iconify/react';
|
||||||
|
|
||||||
|
interface SectionHeaderProps {
|
||||||
|
menu?: React.ReactElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const SectionHeader: React.FC<SectionHeaderProps> = React.memo(
|
||||||
|
(props) => {
|
||||||
|
const [visible, setVisible] = useState(false);
|
||||||
|
return (
|
||||||
|
<div className="h-12 relative flex items-center px-4 py-0 text-base font-bold flex-shrink-0 thin-line-bottom">
|
||||||
|
{React.isValidElement(props.menu) ? (
|
||||||
|
<Dropdown
|
||||||
|
visible={visible}
|
||||||
|
onVisibleChange={setVisible}
|
||||||
|
overlay={props.menu}
|
||||||
|
placement="topRight"
|
||||||
|
trigger={['click']}
|
||||||
|
>
|
||||||
|
<div className="cursor-pointer flex flex-1">
|
||||||
|
<header className="flex-1 truncate">{props.children}</header>
|
||||||
|
<Icon className="text-2xl" icon="mdi-chevron-down">
|
||||||
|

|
||||||
|
</Icon>
|
||||||
|
</div>
|
||||||
|
</Dropdown>
|
||||||
|
) : (
|
||||||
|
<header className="flex-1 truncate">{props.children}</header>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
SectionHeader.displayName = 'SectionHeader';
|
@ -0,0 +1,48 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Menu } from 'antd';
|
||||||
|
import _isNil from 'lodash/isNil';
|
||||||
|
// import { useGroupHeaderAction } from './useGroupHeaderAction';
|
||||||
|
import { useGroupInfo, useTranslation } from 'tailchat-shared';
|
||||||
|
import { SectionHeader } from '@/components/SectionHeader';
|
||||||
|
|
||||||
|
interface GroupHeaderProps {
|
||||||
|
groupId: string;
|
||||||
|
}
|
||||||
|
export const GroupHeader: React.FC<GroupHeaderProps> = React.memo((props) => {
|
||||||
|
const { groupId } = props;
|
||||||
|
const groupInfo = useGroupInfo(groupId);
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
// const {
|
||||||
|
// handleShowGroupInfo,
|
||||||
|
// handleShowInvite,
|
||||||
|
// handleCreateGroupPanel,
|
||||||
|
// handleQuitGroup,
|
||||||
|
// } = useGroupHeaderAction(groupInfo!);
|
||||||
|
|
||||||
|
if (_isNil(groupInfo)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const menu = (
|
||||||
|
<Menu>
|
||||||
|
{/* TODO */}
|
||||||
|
<Menu.Item key="0" onClick={() => console.log('查看详情')}>
|
||||||
|
{t('查看详情')}
|
||||||
|
</Menu.Item>
|
||||||
|
{/* <Menu.Item onClick={handleShowGroupInfo}>{t('查看详情')}</Menu.Item> */}
|
||||||
|
{/* {isGroupManager && (
|
||||||
|
<Menu.Item onClick={handleShowInvite}>{t('邀请成员')}</Menu.Item>
|
||||||
|
)}
|
||||||
|
{isGroupManager && (
|
||||||
|
<Menu.Item onClick={handleCreateGroupPanel}>{t('创建面板')}</Menu.Item>
|
||||||
|
)}
|
||||||
|
<Menu.Item danger={true} onClick={handleQuitGroup}>
|
||||||
|
{currentUserUUID === groupInfo.owner_uuid ? t('解散团') : t('退出团')}
|
||||||
|
</Menu.Item> */}
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
|
|
||||||
|
return <SectionHeader menu={menu}>{groupInfo?.name}</SectionHeader>;
|
||||||
|
});
|
||||||
|
GroupHeader.displayName = 'GroupHeader';
|
Loading…
Reference in New Issue