Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
·
6cb7c42
1
Parent(s):
6dc5da0
fix: 解决仍能发送空白消息的问题
Browse files- assets/custom.js +11 -9
assets/custom.js
CHANGED
@@ -140,15 +140,7 @@ function selectHistory() {
|
|
140 |
user_input_ta = user_input_tb.querySelector("textarea");
|
141 |
if (user_input_ta) {
|
142 |
observer.disconnect(); // 停止监听
|
143 |
-
|
144 |
-
// 在 textarea 上监听 input 事件
|
145 |
-
user_input_ta.addEventListener('input', () => {
|
146 |
-
if (user_input_ta.value.trim() === '') {
|
147 |
-
sendBtn.disabled = true;
|
148 |
-
} else {
|
149 |
-
sendBtn.disabled = false;
|
150 |
-
}
|
151 |
-
});
|
152 |
// 在 textarea 上监听 keydown 事件
|
153 |
user_input_ta.addEventListener("keydown", function (event) {
|
154 |
var value = user_input_ta.value.trim();
|
@@ -193,6 +185,13 @@ function selectHistory() {
|
|
193 |
}
|
194 |
}
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
var username = null;
|
197 |
function getUserInfo() {
|
198 |
if (usernameGotten) {
|
@@ -460,6 +459,7 @@ var mObserver = new MutationObserver(function (mutationsList) {
|
|
460 |
for (var node of mmutation.addedNodes) {
|
461 |
if (node.nodeType === 1 && node.classList.contains('message') && node.getAttribute('data-testid') === 'bot') {
|
462 |
saveHistoryHtml();
|
|
|
463 |
document.querySelectorAll('#chuanhu_chatbot>.wrap>.message-wrap .message.bot').forEach(addChuanhuButton);
|
464 |
}
|
465 |
if (node.tagName === 'INPUT' && node.getAttribute('type') === 'range') {
|
@@ -469,6 +469,7 @@ var mObserver = new MutationObserver(function (mutationsList) {
|
|
469 |
for (var node of mmutation.removedNodes) {
|
470 |
if (node.nodeType === 1 && node.classList.contains('message') && node.getAttribute('data-testid') === 'bot') {
|
471 |
saveHistoryHtml();
|
|
|
472 |
document.querySelectorAll('#chuanhu_chatbot>.wrap>.message-wrap .message.bot').forEach(addChuanhuButton);
|
473 |
}
|
474 |
}
|
@@ -481,6 +482,7 @@ var mObserver = new MutationObserver(function (mutationsList) {
|
|
481 |
isThrottled = false;
|
482 |
document.querySelectorAll('#chuanhu_chatbot>.wrap>.message-wrap .message.bot').forEach(addChuanhuButton);
|
483 |
saveHistoryHtml();
|
|
|
484 |
}, 500);
|
485 |
}
|
486 |
}
|
|
|
140 |
user_input_ta = user_input_tb.querySelector("textarea");
|
141 |
if (user_input_ta) {
|
142 |
observer.disconnect(); // 停止监听
|
143 |
+
disableSendBtn();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
// 在 textarea 上监听 keydown 事件
|
145 |
user_input_ta.addEventListener("keydown", function (event) {
|
146 |
var value = user_input_ta.value.trim();
|
|
|
185 |
}
|
186 |
}
|
187 |
|
188 |
+
function disableSendBtn() {
|
189 |
+
sendBtn.disabled = user_input_ta.value.trim() === '';
|
190 |
+
user_input_ta.addEventListener('input', () => {
|
191 |
+
sendBtn.disabled = user_input_ta.value.trim() === '';
|
192 |
+
});
|
193 |
+
}
|
194 |
+
|
195 |
var username = null;
|
196 |
function getUserInfo() {
|
197 |
if (usernameGotten) {
|
|
|
459 |
for (var node of mmutation.addedNodes) {
|
460 |
if (node.nodeType === 1 && node.classList.contains('message') && node.getAttribute('data-testid') === 'bot') {
|
461 |
saveHistoryHtml();
|
462 |
+
disableSendBtn();
|
463 |
document.querySelectorAll('#chuanhu_chatbot>.wrap>.message-wrap .message.bot').forEach(addChuanhuButton);
|
464 |
}
|
465 |
if (node.tagName === 'INPUT' && node.getAttribute('type') === 'range') {
|
|
|
469 |
for (var node of mmutation.removedNodes) {
|
470 |
if (node.nodeType === 1 && node.classList.contains('message') && node.getAttribute('data-testid') === 'bot') {
|
471 |
saveHistoryHtml();
|
472 |
+
disableSendBtn();
|
473 |
document.querySelectorAll('#chuanhu_chatbot>.wrap>.message-wrap .message.bot').forEach(addChuanhuButton);
|
474 |
}
|
475 |
}
|
|
|
482 |
isThrottled = false;
|
483 |
document.querySelectorAll('#chuanhu_chatbot>.wrap>.message-wrap .message.bot').forEach(addChuanhuButton);
|
484 |
saveHistoryHtml();
|
485 |
+
disableSendBtn();
|
486 |
}, 500);
|
487 |
}
|
488 |
}
|