feat: 增强输入框状态管理,添加禁用状态和恢复输入状态的逻辑

This commit is contained in:
Roe-xin
2025-12-31 18:13:21 +08:00
parent 3d535fd3e1
commit 8762eacb3e
2 changed files with 28 additions and 0 deletions

View File

@ -197,6 +197,11 @@ export function getInputAreaStyles(): string {
overflow-y: auto;
line-height: 1.5;
}
textarea:disabled {
opacity: 0.5;
cursor: not-allowed;
background: rgba(128, 128, 128, 0.1);
}
/* 简洁的滚动条样式 */
textarea::-webkit-scrollbar {
width: 8px;
@ -300,11 +305,17 @@ export function getInputAreaScript(): string {
sendIconContainer.style.display = 'none';
stopIconContainer.style.display = 'block';
isConversationActive = true;
// 禁用输入框
messageInput.disabled = true;
messageInput.placeholder = '正在处理中,请稍候...';
} else {
sendButton.classList.remove('sending');
sendIconContainer.style.display = 'block';
stopIconContainer.style.display = 'none';
isConversationActive = false;
// 启用输入框
messageInput.disabled = false;
messageInput.placeholder = '输入您的问题,按 Enter 发送Shift + Enter 换行...';
}
}
@ -324,6 +335,11 @@ export function getInputAreaScript(): string {
const text = messageInput.value.trim();
if (!text) return;
// 如果正在对话中,阻止发送新消息
if (isConversationActive) {
return;
}
// 检查工作区状态
if (!hasWorkspace) {
// 如果没有工作区,阻止发送并清空输入框