From bac19202b75c4f5c47caab1a0aa5a70b29381d1c Mon Sep 17 00:00:00 2001 From: hz4th_coder Date: Mon, 17 Aug 2026 23:40:33 +0800 Subject: [PATCH] =?UTF-8?q?v1.2.7=20=E8=BE=93=E5=85=A5=E6=A1=86=E5=A4=9A?= =?UTF-8?q?=E8=A1=8C=E8=87=AA=E9=80=82=E5=BA=94=EF=BC=9A=E8=B6=85=E4=B8=80?= =?UTF-8?q?=E8=A1=8C=E8=87=AA=E5=8A=A8=E5=A2=9E=E9=AB=98=EF=BC=8C=E6=9C=80?= =?UTF-8?q?=E5=A4=9A4=E8=A1=8C(90px)=E5=86=85=E9=83=A8=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=EF=BC=9BEnter=E5=8F=91=E9=80=81/Shift+Enter=E6=8D=A2=E8=A1=8C?= =?UTF-8?q?=EF=BC=9B=E5=8F=91=E9=80=81=E5=90=8E=E9=AB=98=E5=BA=A6=E5=A4=8D?= =?UTF-8?q?=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/app.js | 19 +++++++++++++++++-- static/index.html | 2 +- static/style.css | 4 +++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/static/app.js b/static/app.js index a469bd2..ea2df9d 100644 --- a/static/app.js +++ b/static/app.js @@ -181,8 +181,22 @@ async function sendChat(text) { $("#send-btn").disabled = false; } } -$("#send-btn").addEventListener("click", () => { const v = $("#chat-input").value.trim(); if (v) { $("#chat-input").value = ""; sendChat(v); } }); -$("#chat-input").addEventListener("keydown", (e) => { if (e.key === "Enter") $("#send-btn").click(); }); +$("#send-btn").addEventListener("click", () => { const v = $("#chat-input").value.trim(); if (v) { $("#chat-input").value = ""; autoResizeInput(); sendChat(v); } }); + +/* 输入框多行自适应:超一行自动增高,最多 4 行(约90px);Enter 发送,Shift+Enter 换行 */ +const chatInput = $("#chat-input"); +const INPUT_MAX_H = 90; +function autoResizeInput() { + chatInput.style.height = "auto"; + chatInput.style.height = Math.min(chatInput.scrollHeight, INPUT_MAX_H) + "px"; +} +chatInput.addEventListener("input", autoResizeInput); +chatInput.addEventListener("keydown", (e) => { + if (e.key === "Enter" && !e.shiftKey) { + e.preventDefault(); + $("#send-btn").click(); + } +}); /* 复制当前回答(纯文本) */ function copyMsg(btn) { @@ -260,6 +274,7 @@ $("#clear-btn").addEventListener("click", clearChat); /* 快捷问题:点击 → 自动填入输入框并自动提交(需求2) */ function askQuick(q) { $("#chat-input").value = q; + autoResizeInput(); sendChat(q); } diff --git a/static/index.html b/static/index.html index 822604a..c3134fe 100644 --- a/static/index.html +++ b/static/index.html @@ -49,7 +49,7 @@
- +
diff --git a/static/style.css b/static/style.css index 39fb612..8855e40 100644 --- a/static/style.css +++ b/static/style.css @@ -109,7 +109,9 @@ main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px 16 .chips button:hover { border-color: var(--orange2); color: var(--orange2); } .input-bar { display: flex; gap: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 10px 8px 18px; } -#chat-input { flex: 1; background: transparent; border: none; outline: none; color: var(--txt); font-size: 15px; } +#chat-input { flex: 1; background: transparent; border: none; outline: none; color: var(--txt); font-size: 15px; line-height: 1.5; resize: none; overflow-y: auto; max-height: 90px; padding: 5px 0; font-family: inherit; } +#chat-input::-webkit-scrollbar { width: 5px; } +#chat-input::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; } #send-btn { background: linear-gradient(135deg, #f97316, #ea580c); border: none; color: #fff; padding: 10px 24px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 600; } #send-btn:disabled { opacity: .5; cursor: wait; }