From d4cf407cd1cc5a1a72c780e52179350ec6629304 Mon Sep 17 00:00:00 2001 From: kicer Date: Mon, 31 Aug 2026 14:38:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=8D=A2=E8=A1=8C=EF=BC=9AEnter=20=E4=BB=8D=E4=B8=BA=E5=8F=91?= =?UTF-8?q?=E9=80=81=EF=BC=8CCtrl/=E2=8C=98/=E2=8C=A5+Enter=EF=BC=88?= =?UTF-8?q?=E5=8F=8A=20Shift+Enter=EF=BC=89=E5=9C=A8=E5=85=89=E6=A0=87?= =?UTF-8?q?=E5=A4=84=E6=8F=92=E5=85=A5=E6=8D=A2=E8=A1=8C=E5=B9=B6=E8=81=94?= =?UTF-8?q?=E5=8A=A8=E9=AB=98=E5=BA=A6=E8=87=AA=E9=80=82=E5=BA=94=EF=BC=9B?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20IME=20isComposing=20=E9=98=B2=E6=8A=A4?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E4=B8=AD=E6=96=87=E5=80=99=E9=80=89=E5=9B=9E?= =?UTF-8?q?=E8=BD=A6=E8=AF=AF=E5=8F=91=E9=80=81=EF=BC=9B.msg.me=20.msg-bub?= =?UTF-8?q?ble=20=E5=8A=A0=20white-space:pre-wrap=20=E4=BD=BF=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=90=8E=E7=9A=84=E5=A4=9A=E8=A1=8C=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E6=8D=A2=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/server/public/css/style.css | 2 +- app/server/public/js/app.js | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index e3939f6..e4fb2ac 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -110,7 +110,7 @@ body { word-break: break-word; overflow-wrap: break-word; font-size: 14.5px; background: #fff; box-shadow: 0 1px 3px rgba(30,40,90,0.07); } -.msg.me .msg-bubble { background: #d7e7ff; border-bottom-right-radius: 4px; } +.msg.me .msg-bubble { background: #d7e7ff; border-bottom-right-radius: 4px; white-space: pre-wrap; } .msg.other .msg-bubble { border-bottom-left-radius: 4px; } .msg-bubble pre { background: #f0f2f6; padding: 8px 10px; border-radius: 8px; diff --git a/app/server/public/js/app.js b/app/server/public/js/app.js index 7dd2582..fdc13f2 100644 --- a/app/server/public/js/app.js +++ b/app/server/public/js/app.js @@ -452,10 +452,21 @@ document.addEventListener('input', e => { } }); document.addEventListener('keydown', e => { - if (e.target.id === 'msg-input' && e.key === 'Enter' && !e.shiftKey) { + if (e.target.id !== 'msg-input' || e.key !== 'Enter') return; + if (e.isComposing) return; // 中文输入法候选中,回车不拦截 + // Ctrl/⌘/⌥ + Enter(或 Shift + Enter)→ 插入换行 + if (e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) { e.preventDefault(); - ui.send(); + const ta = e.target; + const s = ta.selectionStart; + ta.value = ta.value.slice(0, s) + '\n' + ta.value.slice(ta.selectionEnd); + ta.selectionStart = ta.selectionEnd = s + 1; + ta.style.height = 'auto'; + ta.style.height = Math.min(ta.scrollHeight, 120) + 'px'; + return; } + e.preventDefault(); + ui.send(); }); // ---------- 启动 ----------