feat: 增强输入框状态管理,添加禁用状态和恢复输入状态的逻辑
This commit is contained in:
@ -96,6 +96,12 @@ export async function handleUserMessage(
|
|||||||
text: "后端服务不可用",
|
text: "后端服务不可用",
|
||||||
type: "error",
|
type: "error",
|
||||||
});
|
});
|
||||||
|
// 恢复输入状态
|
||||||
|
panel.webview.postMessage({
|
||||||
|
command: "updateSegments",
|
||||||
|
segments: [],
|
||||||
|
isComplete: true,
|
||||||
|
});
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -255,6 +261,12 @@ async function handleUserMessageWithBackend(
|
|||||||
command: "receiveMessage",
|
command: "receiveMessage",
|
||||||
text: `❌ 错误: ${message}`,
|
text: `❌ 错误: ${message}`,
|
||||||
});
|
});
|
||||||
|
// 恢复输入状态
|
||||||
|
panel.webview.postMessage({
|
||||||
|
command: "updateSegments",
|
||||||
|
segments: [],
|
||||||
|
isComplete: true,
|
||||||
|
});
|
||||||
reject(new Error(message));
|
reject(new Error(message));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -197,6 +197,11 @@ export function getInputAreaStyles(): string {
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
textarea:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
background: rgba(128, 128, 128, 0.1);
|
||||||
|
}
|
||||||
/* 简洁的滚动条样式 */
|
/* 简洁的滚动条样式 */
|
||||||
textarea::-webkit-scrollbar {
|
textarea::-webkit-scrollbar {
|
||||||
width: 8px;
|
width: 8px;
|
||||||
@ -300,11 +305,17 @@ export function getInputAreaScript(): string {
|
|||||||
sendIconContainer.style.display = 'none';
|
sendIconContainer.style.display = 'none';
|
||||||
stopIconContainer.style.display = 'block';
|
stopIconContainer.style.display = 'block';
|
||||||
isConversationActive = true;
|
isConversationActive = true;
|
||||||
|
// 禁用输入框
|
||||||
|
messageInput.disabled = true;
|
||||||
|
messageInput.placeholder = '正在处理中,请稍候...';
|
||||||
} else {
|
} else {
|
||||||
sendButton.classList.remove('sending');
|
sendButton.classList.remove('sending');
|
||||||
sendIconContainer.style.display = 'block';
|
sendIconContainer.style.display = 'block';
|
||||||
stopIconContainer.style.display = 'none';
|
stopIconContainer.style.display = 'none';
|
||||||
isConversationActive = false;
|
isConversationActive = false;
|
||||||
|
// 启用输入框
|
||||||
|
messageInput.disabled = false;
|
||||||
|
messageInput.placeholder = '输入您的问题,按 Enter 发送,Shift + Enter 换行...';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,6 +335,11 @@ export function getInputAreaScript(): string {
|
|||||||
const text = messageInput.value.trim();
|
const text = messageInput.value.trim();
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
|
|
||||||
|
// 如果正在对话中,阻止发送新消息
|
||||||
|
if (isConversationActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 检查工作区状态
|
// 检查工作区状态
|
||||||
if (!hasWorkspace) {
|
if (!hasWorkspace) {
|
||||||
// 如果没有工作区,阻止发送并清空输入框
|
// 如果没有工作区,阻止发送并清空输入框
|
||||||
|
|||||||
Reference in New Issue
Block a user