优化消息组件显示逻辑
This commit is contained in:
parent
0447cc9743
commit
9058f4a7f1
@ -223,20 +223,30 @@ function PureMessages({
|
||||
|
||||
{/* 等待动画:根据模型类型显示不同的加载效果 */}
|
||||
{/* 🆕 支持恢复的生成状态(用户离开再返回) */}
|
||||
{(showThinkingWithDelay || (pendingGeneration && status === "ready")) && (
|
||||
(() => {
|
||||
// 优先使用恢复的状态,否则使用当前模型类型
|
||||
const modelType = pendingGeneration?.modelType;
|
||||
const showGemini = modelType === "gemini" || (!modelType && isGeminiModel);
|
||||
const showVolcano = modelType === "volcano-vision" || (!modelType && isVolcanoVisionModel);
|
||||
const showVideo = modelType === "volcano-video" || modelType === "qianwen-video" || (!modelType && (isQianwenVideoModel || isVideoModel));
|
||||
|
||||
if (showVideo) return <QianwenVideoLoading />;
|
||||
if (showGemini) return <GeminiImageLoading />;
|
||||
if (showVolcano) return <VolcanoVisionLoading />;
|
||||
return <ThinkingMessage />;
|
||||
})()
|
||||
)}
|
||||
{(() => {
|
||||
// 检查最后一条消息是否是用户消息(表示还在等待 AI 响应)
|
||||
const lastMessage = messages.length > 0 ? messages[messages.length - 1] : null;
|
||||
const isWaitingForResponse = lastMessage?.role === "user";
|
||||
|
||||
// 恢复的待处理状态:有 pendingGeneration 且最后一条是用户消息
|
||||
const hasRestoredPending = pendingGeneration && isWaitingForResponse;
|
||||
|
||||
// 显示条件:正常等待动画 或 恢复的待处理状态
|
||||
const shouldShow = showThinkingWithDelay || hasRestoredPending;
|
||||
|
||||
if (!shouldShow) return null;
|
||||
|
||||
// 优先使用恢复的状态,否则使用当前模型类型
|
||||
const modelType = pendingGeneration?.modelType;
|
||||
const showGemini = modelType === "gemini" || (!modelType && isGeminiModel);
|
||||
const showVolcano = modelType === "volcano-vision" || (!modelType && isVolcanoVisionModel);
|
||||
const showVideo = modelType === "volcano-video" || modelType === "qianwen-video" || (!modelType && (isQianwenVideoModel || isVideoModel));
|
||||
|
||||
if (showVideo) return <QianwenVideoLoading />;
|
||||
if (showGemini) return <GeminiImageLoading />;
|
||||
if (showVolcano) return <VolcanoVisionLoading />;
|
||||
return <ThinkingMessage />;
|
||||
})()}
|
||||
|
||||
<div
|
||||
className="min-h-[24px] min-w-[24px] shrink-0"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user