Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
·
6dc5da0
1
Parent(s):
31c04be
feat: 在前端禁止发送空白消息
Browse files- assets/custom.js +12 -3
assets/custom.js
CHANGED
@@ -19,6 +19,7 @@ var messageBotDivs = null;
|
|
19 |
var loginUserForm = null;
|
20 |
var logginUser = null;
|
21 |
var updateToast = null;
|
|
|
22 |
|
23 |
var userLogged = false;
|
24 |
var usernameGotten = false;
|
@@ -72,6 +73,7 @@ function gradioLoaded(mutations) {
|
|
72 |
chatbotWrap = document.querySelector('#chuanhu_chatbot > .wrap');
|
73 |
apSwitch = document.querySelector('.apSwitch input[type="checkbox"]');
|
74 |
updateToast = document.querySelector("#toast-update");
|
|
|
75 |
|
76 |
if (loginUserForm) {
|
77 |
localStorage.setItem("userLogged", true);
|
@@ -102,7 +104,7 @@ function gradioLoaded(mutations) {
|
|
102 |
if (updateToast) {
|
103 |
const lastCheckTime = localStorage.getItem('lastCheckTime') || 0;
|
104 |
const longTimeNoCheck = currentTime - lastCheckTime > 3 * 24 * 60 * 60 * 1000;
|
105 |
-
if (longTimeNoCheck && !updateInfoGotten && !isLatestVersion || isLatestVersion && !updateInfoGotten
|
106 |
updateLatestVersion();
|
107 |
}
|
108 |
}
|
@@ -138,6 +140,15 @@ function selectHistory() {
|
|
138 |
user_input_ta = user_input_tb.querySelector("textarea");
|
139 |
if (user_input_ta) {
|
140 |
observer.disconnect(); // 停止监听
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
// 在 textarea 上监听 keydown 事件
|
142 |
user_input_ta.addEventListener("keydown", function (event) {
|
143 |
var value = user_input_ta.value.trim();
|
@@ -220,8 +231,6 @@ function toggleUserInfoVisibility(shouldHide) {
|
|
220 |
}
|
221 |
}
|
222 |
function showOrHideUserInfo() {
|
223 |
-
var sendBtn = document.getElementById("submit_btn");
|
224 |
-
|
225 |
// Bind mouse/touch events to show/hide user info
|
226 |
appTitleDiv.addEventListener("mouseenter", function () {
|
227 |
toggleUserInfoVisibility(false);
|
|
|
19 |
var loginUserForm = null;
|
20 |
var logginUser = null;
|
21 |
var updateToast = null;
|
22 |
+
var sendBtn = null;
|
23 |
|
24 |
var userLogged = false;
|
25 |
var usernameGotten = false;
|
|
|
73 |
chatbotWrap = document.querySelector('#chuanhu_chatbot > .wrap');
|
74 |
apSwitch = document.querySelector('.apSwitch input[type="checkbox"]');
|
75 |
updateToast = document.querySelector("#toast-update");
|
76 |
+
sendBtn = document.getElementById("submit_btn");
|
77 |
|
78 |
if (loginUserForm) {
|
79 |
localStorage.setItem("userLogged", true);
|
|
|
104 |
if (updateToast) {
|
105 |
const lastCheckTime = localStorage.getItem('lastCheckTime') || 0;
|
106 |
const longTimeNoCheck = currentTime - lastCheckTime > 3 * 24 * 60 * 60 * 1000;
|
107 |
+
if (longTimeNoCheck && !updateInfoGotten && !isLatestVersion || isLatestVersion && !updateInfoGotten) {
|
108 |
updateLatestVersion();
|
109 |
}
|
110 |
}
|
|
|
140 |
user_input_ta = user_input_tb.querySelector("textarea");
|
141 |
if (user_input_ta) {
|
142 |
observer.disconnect(); // 停止监听
|
143 |
+
sendBtn.disabled = true
|
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();
|
|
|
231 |
}
|
232 |
}
|
233 |
function showOrHideUserInfo() {
|
|
|
|
|
234 |
// Bind mouse/touch events to show/hide user info
|
235 |
appTitleDiv.addEventListener("mouseenter", function () {
|
236 |
toggleUserInfoVisibility(false);
|