diff --git a/components/AIChatWidget.tsx b/components/AIChatWidget.tsx index e86f67e..a8d4f51 100644 --- a/components/AIChatWidget.tsx +++ b/components/AIChatWidget.tsx @@ -4,12 +4,23 @@ import { useState, useEffect, useRef } from 'react' import { useSession } from 'next-auth/react' import Image from 'next/image' -// 添加shimmer动画样式 +// 添加动画样式 const shimmerStyle = ` @keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } } + + @keyframes breathe { + 0%, 100% { + filter: blur(15px) brightness(0.7); + transform: scale(1); + } + 50% { + filter: blur(12px) brightness(0.8); + transform: scale(1.02); + } + } ` // 图片加载占位符组件 @@ -55,6 +66,7 @@ interface Message { timestamp: Date isGenerating?: boolean // 是否正在生成图片 imageCount?: number // 预期生成的图片数量 + sourceImages?: string[] // 用户发送的原始图片(用于显示模糊占位符) } export default function AIChatWidget() { @@ -256,7 +268,8 @@ export default function AIChatWidget() { content: '', timestamp: new Date(), isGenerating: shouldShowImagePlaceholder, - imageCount: shouldShowImagePlaceholder ? 4 : 0 + imageCount: shouldShowImagePlaceholder ? 4 : 0, + sourceImages: currentImages.length > 0 ? currentImages : undefined // 保存用户发送的原图 } setMessages(prev => [...prev, tempAiMessage]) @@ -414,31 +427,78 @@ export default function AIChatWidget() { } rounded-lg px-4 py-3`}> {msg.content &&
{msg.content}
} - {/* 显示图片加载占位符 - 横向一排4个 */} - {msg.isGenerating && msg.imageCount && msg.imageCount > 0 && ( -
- {Array.from({ length: msg.imageCount }).map((_, idx) => ( -
- + {/* 显示图片加载占位符 */} + {msg.isGenerating && ( +
+ {/* 如果有原图,显示原图的模糊占位符 */} + {msg.sourceImages && msg.sourceImages.length > 0 ? ( +
+ {msg.sourceImages.map((img, idx) => ( +
+ {`Processing +
+
+
+
+
+
+
+ AI处理中... +
+
+
+
+ ))}
- ))} + ) : ( + /* 没有原图,显示4个空白占位符(生成任务) */ + msg.imageCount && msg.imageCount > 0 && ( +
+ {Array.from({ length: msg.imageCount }).map((_, idx) => ( +
+ +
+ ))} +
+ ) + )}
)} - {/* 显示实际图片 - 横向一排显示 */} + {/* 显示实际图片 - 添加淡入动画 */} {!msg.isGenerating && msg.images && msg.images.length > 0 && ( -
{msg.images.map((img, idx) => ( -
+
{`Image { // 点击图片在新窗口打开 const win = window.open()