From 2982ee3e061d1f4386e004f6a37a85c05cee8f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BD=8A=E5=B0=BC=E6=9B=BC?= <97031067+chienniman@users.noreply.github.com> Date: Sun, 11 Jun 2023 12:35:49 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=E4=BF=AE=E5=BE=A9=E5=82=B3=E9=80=81?= =?UTF-8?q?=E7=A9=BA=E7=99=BD=EF=BC=8C=E5=8E=BB=E9=99=A4=E9=A6=96=E5=B0=BE?= =?UTF-8?q?=E7=A9=BA=E7=99=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Applications/Chat/Web/index.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Applications/Chat/Web/index.php b/Applications/Chat/Web/index.php index 57576da..6e95496 100644 --- a/Applications/Chat/Web/index.php +++ b/Applications/Chat/Web/index.php @@ -112,7 +112,10 @@ function onSubmit() { var input = document.getElementById("textarea"); var to_client_id = $("#client_list option:selected").attr("value"); var to_client_name = $("#client_list option:selected").text(); - ws.send('{"type":"say","to_client_id":"'+to_client_id+'","to_client_name":"'+to_client_name+'","content":"'+input.value.replace(/"/g, '\\"').replace(/\n/g,'\\n').replace(/\r/g, '\\r')+'"}'); + var content = input.value.trim(); + if (content !== "") { + ws.send('{"type":"say","to_client_id":"' + to_client_id + '","to_client_name":"' + to_client_name + '","content":"' + content.replace(/"/g, '\\"').replace(/\n/g,'\\n').replace(/\r/g, '\\r') + '"}'); + } input.value = ""; input.focus(); }