feat: auto-scroll and collapse thinking blocks
This commit is contained in:
parent
19c0e9d04b
commit
e7a81f00e7
@ -684,6 +684,9 @@ async function bootstrapApp() {
|
|||||||
if (status.conversation && status.conversation.current_id) {
|
if (status.conversation && status.conversation.current_id) {
|
||||||
this.currentConversationId = status.conversation.current_id;
|
this.currentConversationId = status.conversation.current_id;
|
||||||
}
|
}
|
||||||
|
if (typeof status.thinking_mode !== 'undefined') {
|
||||||
|
this.thinkingMode = !!status.thinking_mode;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// AI消息开始
|
// AI消息开始
|
||||||
@ -723,7 +726,12 @@ async function bootstrapApp() {
|
|||||||
msg.actions.push(action);
|
msg.actions.push(action);
|
||||||
|
|
||||||
const blockId = `${this.currentMessageIndex}-thinking-${msg.actions.length - 1}`;
|
const blockId = `${this.currentMessageIndex}-thinking-${msg.actions.length - 1}`;
|
||||||
|
action.blockId = blockId;
|
||||||
this.expandedBlocks.add(blockId);
|
this.expandedBlocks.add(blockId);
|
||||||
|
// 开始思考时自动锁定滚动到底部
|
||||||
|
this.autoScrollEnabled = true;
|
||||||
|
this.userScrolling = false;
|
||||||
|
this.scrollToBottom();
|
||||||
this.$forceUpdate();
|
this.$forceUpdate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -752,6 +760,12 @@ async function bootstrapApp() {
|
|||||||
if (lastAction && lastAction.type === 'thinking') {
|
if (lastAction && lastAction.type === 'thinking') {
|
||||||
lastAction.streaming = false;
|
lastAction.streaming = false;
|
||||||
lastAction.content = data.full_content;
|
lastAction.content = data.full_content;
|
||||||
|
if (lastAction.blockId) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.expandedBlocks.delete(lastAction.blockId);
|
||||||
|
this.$forceUpdate();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
msg.streamingThinking = '';
|
msg.streamingThinking = '';
|
||||||
msg.currentStreamingType = null;
|
msg.currentStreamingType = null;
|
||||||
@ -1990,12 +2004,8 @@ async function bootstrapApp() {
|
|||||||
body: JSON.stringify({ thinking_mode: !this.thinkingMode })
|
body: JSON.stringify({ thinking_mode: !this.thinkingMode })
|
||||||
});
|
});
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
if (data.success && data.data) {
|
if (data.success) {
|
||||||
if (typeof data.data === 'object') {
|
this.thinkingMode = !!data.data;
|
||||||
this.thinkingMode = !!data.data.enabled;
|
|
||||||
} else {
|
|
||||||
this.thinkingMode = data.data === '思考模式';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(data.message || data.error || '切换失败');
|
throw new Error(data.message || data.error || '切换失败');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1084,7 +1084,11 @@ async function bootstrapApp() {
|
|||||||
msg.actions.push(action);
|
msg.actions.push(action);
|
||||||
|
|
||||||
const blockId = `${this.currentMessageIndex}-thinking-${msg.actions.length - 1}`;
|
const blockId = `${this.currentMessageIndex}-thinking-${msg.actions.length - 1}`;
|
||||||
|
action.blockId = blockId;
|
||||||
this.expandedBlocks.add(blockId);
|
this.expandedBlocks.add(blockId);
|
||||||
|
this.autoScrollEnabled = true;
|
||||||
|
this.userScrolling = false;
|
||||||
|
this.scrollToBottom();
|
||||||
this.$forceUpdate();
|
this.$forceUpdate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1113,6 +1117,12 @@ async function bootstrapApp() {
|
|||||||
if (lastAction && lastAction.type === 'thinking') {
|
if (lastAction && lastAction.type === 'thinking') {
|
||||||
lastAction.streaming = false;
|
lastAction.streaming = false;
|
||||||
lastAction.content = data.full_content;
|
lastAction.content = data.full_content;
|
||||||
|
if (lastAction.blockId) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.expandedBlocks.delete(lastAction.blockId);
|
||||||
|
this.$forceUpdate();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
msg.streamingThinking = '';
|
msg.streamingThinking = '';
|
||||||
msg.currentStreamingType = null;
|
msg.currentStreamingType = null;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user