feat: 为通用消息列表增加消息头

pull/56/head
moonrailgun 3 years ago
parent 6ed24c7f6f
commit 15741c3b2e

@ -312,6 +312,7 @@
"kfa493f3f": "Reply", "kfa493f3f": "Reply",
"kfaddd61d": "Chat Service", "kfaddd61d": "Chat Service",
"kfbecf2a7": "Are you sure you want to delete the panel group [{{name}}] and all subordinate panels", "kfbecf2a7": "Are you sure you want to delete the panel group [{{name}}] and all subordinate panels",
"kfc07c0a4": "Here is the beginning of all messages, please feel free to speak up.",
"kfd340bbc": "Manage members", "kfd340bbc": "Manage members",
"kfe731dfc": "Action" "kfe731dfc": "Action"
} }

@ -312,6 +312,7 @@
"kfa493f3f": "回复", "kfa493f3f": "回复",
"kfaddd61d": "聊天服务", "kfaddd61d": "聊天服务",
"kfbecf2a7": "确定要删除面板组 【{{name}}】 以及下级的所有面板么", "kfbecf2a7": "确定要删除面板组 【{{name}}】 以及下级的所有面板么",
"kfc07c0a4": "这里是所有消息的开始,请畅所欲言。",
"kfd340bbc": "管理成员", "kfd340bbc": "管理成员",
"kfe731dfc": "操作" "kfe731dfc": "操作"
} }

@ -0,0 +1,20 @@
import React from 'react';
import { Icon } from 'tailchat-design';
import { t } from 'tailchat-shared';
export const ChatMessageHeader: React.FC<{
title: React.ReactNode;
}> = React.memo((props) => {
return (
<div className="px-5 pb-4">
<div className="font-extrabold mb-2 text-2xl flex items-center space-x-1">
<Icon icon="mdi:pound" />
<div>{props.title}</div>
</div>
<div className="text-base opacity-80">
{t('这里是所有消息的开始,请畅所欲言。')}
</div>
</div>
);
});
ChatMessageHeader.displayName = 'ChatMessageHeader';

@ -1,5 +1,6 @@
import React, { useCallback, useEffect, useRef } from 'react'; import React, { useCallback, useEffect, useRef } from 'react';
import { sharedEvent } from 'tailchat-shared'; import { sharedEvent } from 'tailchat-shared';
import { ChatMessageHeader } from './ChatMessageHeader';
import { buildMessageItemRow } from './Item'; import { buildMessageItemRow } from './Item';
import type { MessageListProps } from './types'; import type { MessageListProps } from './types';
@ -60,6 +61,11 @@ export const NormalMessageList: React.FC<MessageListProps> = React.memo(
buildMessageItemRow(arr, index) buildMessageItemRow(arr, index)
)} )}
</div> </div>
{/* 因为是倒过来的,因此要前面的要放在后面 */}
{props.title && !props.hasMoreMessage && (
<ChatMessageHeader title={props.title} />
)}
</div> </div>
); );
} }

@ -2,6 +2,7 @@ import type { ChatMessage } from 'tailchat-shared';
export interface MessageListProps { export interface MessageListProps {
messages: ChatMessage[]; messages: ChatMessage[];
title?: React.ReactNode;
isLoadingMore: boolean; isLoadingMore: boolean;
hasMoreMessage: boolean; hasMoreMessage: boolean;
onLoadMore: () => Promise<void>; onLoadMore: () => Promise<void>;

@ -11,16 +11,18 @@ import { useMessageAck } from './useMessageAck';
type ChatBoxProps = type ChatBoxProps =
| { | {
converseId: string; converseId: string;
converseTitle?: React.ReactNode;
isGroup: false; isGroup: false;
groupId?: string; groupId?: string;
} }
| { | {
converseId: string; converseId: string;
converseTitle?: React.ReactNode;
isGroup: true; isGroup: true;
groupId: string; groupId: string;
}; };
const ChatBoxInner: React.FC<ChatBoxProps> = React.memo((props) => { const ChatBoxInner: React.FC<ChatBoxProps> = React.memo((props) => {
const { converseId, isGroup } = props; const { converseId, converseTitle, isGroup } = props;
const { const {
messages, messages,
loading, loading,
@ -47,6 +49,7 @@ const ChatBoxInner: React.FC<ChatBoxProps> = React.memo((props) => {
<div className="w-full h-full flex flex-col select-text"> <div className="w-full h-full flex flex-col select-text">
<ChatMessageList <ChatMessageList
key={converseId} key={converseId}
title={converseTitle}
messages={messages} messages={messages}
isLoadingMore={isLoadingMore} isLoadingMore={isLoadingMore}
hasMoreMessage={hasMoreMessage} hasMoreMessage={hasMoreMessage}

@ -72,7 +72,7 @@ export const TextPanel: React.FC<TextPanelProps> = React.memo(
const panelInfo = useGroupPanelInfo(groupId, panelId); const panelInfo = useGroupPanelInfo(groupId, panelId);
const { disabled, placeholder } = useChatInputInfo(groupId); const { disabled, placeholder } = useChatInputInfo(groupId);
if (panelInfo === undefined) { if (!panelInfo) {
return null; return null;
} }
@ -86,7 +86,12 @@ export const TextPanel: React.FC<TextPanelProps> = React.memo(
disabled={disabled} disabled={disabled}
placeholder={placeholder} placeholder={placeholder}
> >
<ChatBox converseId={panelId} isGroup={true} groupId={groupId} /> <ChatBox
converseId={panelId}
converseTitle={panelInfo.name}
isGroup={true}
groupId={groupId}
/>
</ChatInputMentionsContextProvider> </ChatInputMentionsContextProvider>
</GroupPanelWrapper> </GroupPanelWrapper>
); );

@ -53,9 +53,13 @@ export const ConversePanel: React.FC<ConversePanelProps> = React.memo(
return <OpenedPanelTip onClosePanelWindow={closePanelWindow} />; return <OpenedPanelTip onClosePanelWindow={closePanelWindow} />;
} }
const converseHeader = converse && (
<ConversePanelTitle converse={converse} />
);
return ( return (
<CommonPanelWrapper <CommonPanelWrapper
header={converse && <ConversePanelTitle converse={converse} />} header={converseHeader}
actions={(setRightPanel) => { actions={(setRightPanel) => {
if (!converse) { if (!converse) {
return []; return [];
@ -134,7 +138,11 @@ export const ConversePanel: React.FC<ConversePanelProps> = React.memo(
]); ]);
}} }}
> >
<ChatBox converseId={converseId} isGroup={false} /> <ChatBox
converseId={converseId}
converseTitle={converseHeader}
isGroup={false}
/>
</CommonPanelWrapper> </CommonPanelWrapper>
); );
} }

Loading…
Cancel
Save