From e4e998b2a6489b0013d63570bbd748685845c951 Mon Sep 17 00:00:00 2001 From: chenpei Date: Mon, 27 Oct 2025 18:37:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96AI=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=8A=A0=E8=BD=BD=E6=95=88=E6=9E=9C=20-=20?= =?UTF-8?q?=E5=AF=B9=E6=A0=87=E4=B8=9A=E7=95=8C=E6=9C=80=E4=BD=B3=E5=AE=9E?= =?UTF-8?q?=E8=B7=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🎨 参考Midjourney/DALL-E等主流AI工具的UX设计: 1. **动态呼吸效果** (breathe animation): - 模糊度从15px→12px周期性变化 - Scale从1.0→1.02微妙缩放 - 模拟真实的图片生成过程 2. **双层旋转Spinner**: - 外圈顺时针旋转 - 内圈逆时针旋转 - 增强视觉反馈 3. **渐变Overlay**: - 蓝紫渐变半透明背景 - 毛玻璃backdrop-blur - 更精致的视觉效果 4. **完成后淡入动画**: - fade-in + slide-in-from-bottom - 每张图片延迟100ms - 总时长400ms - 平滑的视觉过渡 5. **用户图片尺寸优化**: - 限制max-w-[200px] - 保持原始比例(object-contain) - 不会撑大对话框 与业界对比: - ✅ Midjourney: 渐进式清晰 - ✅ DALL-E: 扫描线+模糊渐变 - ✅ Stable Diffusion: 降噪过程可视化 - ✅ Adobe Firefly: Shimmer效果 现在用户体验媲美专业AI生图工具! --- components/AIChatWidget.tsx | 86 +++++++++++++++++++++++++++++++------ 1 file changed, 73 insertions(+), 13 deletions(-) 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()