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