分析时间: 2026-04-10 17:10
分析对象: chat-client/app/components/chat-list.tsx
核心功能:
@hello-pangea/dnd 库依赖:
@hello-pangea/dnd - 拖拽库useChatStore - 需要 moveSession 方法代码量: 174 行
当前实现:
handleSessionClick依赖:
antd - UI 组件库useChatStore - 基础方法代码量: 约 250 行
| 功能 | chat-list.tsx | universalChat Sidebar | 差异 |
|---|---|---|---|
| 拖拽排序 | ✅ 支持 | ❌ 不支持 | 🔴 需要添加 |
| 按日期分组 | ❌ 不支持 | ✅ 支持 | 🟢 已有优势 |
| 删除会话 | ✅ 支持 | ✅ 支持 | ✅ 相同 |
| 重命名会话 | ❌ 不支持 | ✅ 支持 | 🟢 已有优势 |
| 右键菜单 | ❌ 无 | ✅ 支持 | 🟢 已有优势 |
| 收藏应用 | ❌ 无 | ✅ 支持 | 🟢 已有优势 |
| 应用分类 | ❌ 无 | ✅ 支持 | 🟢 已有优势 |
| 搜索功能 | ❌ 无 | ✅ 支持 | 🟢 已有优势 |
做法: 用 chat-list.tsx 完全替换当前 Sidebar 的会话列表部分
问题:
工作量: 4 小时(包含适配和调试)
做法: 在当前 Sidebar 的会话列表基础上添加拖拽功能
优势:
工作量: 2 小时(仅需添加拖拽逻辑)
理由:
建议: 等用户反馈后再决定是否添加拖拽功能
npm install @hello-pangea/dnd
// src/pages/universalChat/store/chatStore.ts
moveSession: (fromIndex: number, toIndex: number) => {
set((state) => {
const newSessions = [...state.sessions];
const [removed] = newSessions.splice(fromIndex, 1);
newSessions.splice(toIndex, 0, removed);
return { sessions: newSessions };
});
},
在"最近对话"部分添加拖拽支持:
import {
DragDropContext,
Droppable,
Draggable,
OnDragEndResponder,
} from "@hello-pangea/dnd";
// 添加拖拽结束处理
const onDragEnd: OnDragEndResponder = (result) => {
if (!result.destination) return;
const { source, destination } = result;
if (source.index === destination.index) return;
moveSession(source.index, destination.index);
};
// 在渲染时使用 DragDropContext
<DragDropContext onDragEnd={onDragEnd}>
<Droppable droppableId="recent-chats">
{(provided) => (
<div ref={provided.innerRef} {...provided.droppableProps}>
{sessions.map((session, index) => (
<Draggable
key={session.id}
draggableId={session.id}
index={index}
>
{(provided) => (
<div
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
className={`chat-item ${currentSessionId === session.id ? 'active' : ''}`}
onClick={() => handleSessionClick(session.id)}
>
<span className="chat-item-title">{session.topic}</span>
<EditOutlined className="chat-item-edit" />
</div>
)}
</Draggable>
))}
{provided.placeholder}
</div>
)}
</Droppable>
</DragDropContext>
.chat-item {
// 拖拽时的样式
&[data-dragging="true"] {
opacity: 0.5;
transform: rotate(3deg);
}
// 拖拽手柄提示
&:hover {
cursor: grab;
}
&:active {
cursor: grabbing;
}
}
@hello-pangea/dnd (~50KB)理由:
推荐方案: 方案 B(保留现有,增强拖拽)
实施条件:
决策时间: 2026-04-10
决策人: [待填写]
决策结果: ⏸️ 暂不迁移
决策理由:
满足以下任一条件时重新评估:
如果用户需要快速找到会话:
评估报告生成完毕 - 等待决策