diff --git a/app/(chat)/api/chat/route.ts b/app/(chat)/api/chat/route.ts index 4bde350..604588e 100644 --- a/app/(chat)/api/chat/route.ts +++ b/app/(chat)/api/chat/route.ts @@ -486,6 +486,8 @@ export async function POST(request: Request) { let bestModel = null; if (hasImage) { bestModel = allModels.find(m => m.model.supportsImageGen && !m.model.isSubModel); + // 🆕 回退时也生成一个友好消息 + smartAutoFriendlyMessage = "好的,我来帮你处理这张图片~"; } if (!bestModel) { bestModel = allModels.find(m => m.model.isDefault && !m.model.isSubModel); @@ -1016,6 +1018,11 @@ export async function POST(request: Request) { parts: [{ type: "text", text: smartAutoFriendlyMessage }], attachments: [], createdAt: new Date(), + videoStorageStatus: null, + temporaryVideoUrl: null, + permanentVideoUrl: null, + archivedAt: null, + videoMetadata: null, }, ], }); @@ -1235,6 +1242,11 @@ export async function POST(request: Request) { parts: [{ type: "text", text: smartAutoFriendlyMessage }], attachments: [], createdAt: new Date(), + videoStorageStatus: null, + temporaryVideoUrl: null, + permanentVideoUrl: null, + archivedAt: null, + videoMetadata: null, }, ], }); diff --git a/components/messages.tsx b/components/messages.tsx index dc32087..7da88f4 100644 --- a/components/messages.tsx +++ b/components/messages.tsx @@ -236,7 +236,7 @@ function PureMessages({ else { setShowThinkingWithDelay(false); } - }, [status, messages, isGeminiModel, isQianwenVideoModel, isVolcanoVisionModel, isVideoModel, isAlibabaImageModel]); + }, [status, messages, isGeminiModel, isQianwenVideoModel, isVolcanoVisionModel, isVideoModel, isAlibabaImageModel, selectedModelId]); // 🆕 监听新消息添加,当用户发送带图片的消息或添加加载消息时,强制滚动到底部 const prevMessagesLengthRef = useRef(messages.length); @@ -365,9 +365,9 @@ function PureMessages({ // 🆕 检查智能自动模式是否有图片(需要显示生图占位图) const isAutoMode = selectedModelId === "auto"; - const userMessageHasImage = messages.length > 0 && - messages[messages.length - 1]?.role === "user" && - messages[messages.length - 1]?.parts?.some((p: any) => p.type === "file" || p.type === "image"); + // 🆕 找用户的最后一条消息(而不是整个对话的最后一条) + const lastUserMsg = [...messages].reverse().find(m => m.role === "user"); + const userMessageHasImage = lastUserMsg?.parts?.some((p: any) => p.type === "file" || p.type === "image"); const showAutoModeImage = isAutoMode && userMessageHasImage; if (showVideo) return ; diff --git a/lib/ai/smart-analyzer.ts b/lib/ai/smart-analyzer.ts index c14a9bb..a51365b 100644 --- a/lib/ai/smart-analyzer.ts +++ b/lib/ai/smart-analyzer.ts @@ -312,13 +312,16 @@ export function fallbackKeywordAnalysis( }; } - // 调色 - if (/调色|调整颜色|亮度|对比度|饱和度|色调|曝光|滤镜/.test(lowerText)) { + // 调色/改颜色 + if (/调色|调整颜色|亮度|对比度|饱和度|色调|曝光|滤镜|改成.*色|换成.*色|变成.*色|颜色改成|颜色换成|颜色变成/.test(lowerText)) { + // 提取目标颜色 + const colorMatch = text.match(/(?:改成|换成|变成)(.+?)(?:色|$)/); + const color = colorMatch ? colorMatch[1].trim() + "色" : ""; return { intent: "image_edit", subIntent: "color_adjust", confidence: 0.9, - conversationalReply: "收到,我来帮你调整图片色彩~", + conversationalReply: color ? `好的,我来帮你把颜色改成${color}~` : "收到,我来帮你调整图片色彩~", }; }