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(); }); // ---------- 启动 ----------