chatbox修复重复key报错问题

This commit is contained in:
北枳 2025-08-26 17:32:24 +08:00
parent 4e87b4a15f
commit 154025a722

View File

@ -246,6 +246,7 @@ export function InputBar({ onSend, setVideoPreview, initialVideoUrl, initialVide
{/* 图片上传按钮 - 单行时显示在左侧 */}
{!isMultiline && (
<motion.label
key="single-line-upload"
initial={{ opacity: 0, scale: 0.8 }}
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.8 }}
@ -264,7 +265,7 @@ export function InputBar({ onSend, setVideoPreview, initialVideoUrl, initialVide
)}
{/* 文本输入 */}
<motion.div layout className="flex-1 flex">
<motion.div layout key="text-input" className="flex-1 flex">
<textarea
ref={textareaRef}
placeholder="输入文字…"
@ -295,6 +296,7 @@ export function InputBar({ onSend, setVideoPreview, initialVideoUrl, initialVide
{isMultiline ? (
// 多行模式:底部按钮区域
<motion.div
key="multi-line-buttons"
layout
initial={{ opacity: 0, y: -10 }}
animate={{ opacity: 1, y: 0 }}
@ -303,6 +305,7 @@ export function InputBar({ onSend, setVideoPreview, initialVideoUrl, initialVide
>
{/* 图片上传 */}
<motion.label
key="multi-line-upload"
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
className={`cursor-pointer inline-flex items-center gap-2 p-2 rounded-full hover:bg-gray-700/50 text-gray-100 ${isUploading ? 'opacity-50 cursor-not-allowed' : ''}`}
@ -333,6 +336,7 @@ export function InputBar({ onSend, setVideoPreview, initialVideoUrl, initialVide
) : (
// 单行模式:发送按钮
<motion.button
key="single-line-send"
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
onClick={handleSend}