Commit bb54d5a2 by HoMeTown

fix: 解决当records为空时的报错问题

parent e6941309
......@@ -49,7 +49,7 @@ export const ChatContent: React.FC = () => {
itemContent={(index, record) => (
<ChatItem record={record} key={record.originalData?.groupId} />
)}
initialTopMostItemIndex={records.length - 1} // 初始滚动到底部
initialTopMostItemIndex={allItems.length - 1} // 初始滚动到底部
followOutput="smooth" // 新消息时平滑滚动到底部
/>
</motion.div>
......
......@@ -10,6 +10,8 @@ const initialState: ChatState = {
function processApiResponse(data: OriginalRecord[]): ChatRecord[] {
const chatRecord: ChatRecord[] = []
if (data.length === 0)
return chatRecord
data.forEach((record) => {
chatRecord.push({
type: 'question',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment