feat: 用自定义侧边栏替换聊天室 Conversations 组件,提取公共 SidebarGroup 和 date-group
This commit is contained in:
45
src/web/features/chat/components/ConversationCard.tsx
Normal file
45
src/web/features/chat/components/ConversationCard.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import { DeleteOutlined } from "@ant-design/icons";
|
||||
import { Button, Flex, Popconfirm, Typography } from "antd";
|
||||
|
||||
import type { Conversation } from "../../../../shared/api";
|
||||
|
||||
interface ConversationCardProps {
|
||||
conversation: Conversation;
|
||||
onDelete: () => void;
|
||||
onSelect: () => void;
|
||||
selected: boolean;
|
||||
}
|
||||
|
||||
export function ConversationCard({ conversation, onDelete, onSelect, selected }: ConversationCardProps) {
|
||||
const className = selected ? "app-sidebar-list-item app-sidebar-list-item--selected" : "app-sidebar-list-item";
|
||||
|
||||
return (
|
||||
<Flex align="center" className={className} gap="small" justify="space-between" onClick={onSelect}>
|
||||
<Typography.Text ellipsis style={{ flex: 1, minWidth: 0 }}>
|
||||
{conversation.title}
|
||||
</Typography.Text>
|
||||
<span className="app-sidebar-item-actions">
|
||||
<Popconfirm
|
||||
description="删除后不可恢复"
|
||||
okButtonProps={{ danger: true }}
|
||||
okText="删除"
|
||||
onCancel={(e) => e?.stopPropagation()}
|
||||
onConfirm={(e) => {
|
||||
e?.stopPropagation();
|
||||
onDelete();
|
||||
}}
|
||||
title="确认删除该对话?"
|
||||
>
|
||||
<Button
|
||||
aria-label="删除"
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
size="small"
|
||||
type="text"
|
||||
/>
|
||||
</Popconfirm>
|
||||
</span>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user