From 283793bc1cdb8682772b0e9879d5eb3014f859b9 Mon Sep 17 00:00:00 2001 From: lkddi Date: Sat, 25 Apr 2026 10:09:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=85=A8=E5=B1=80=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E9=94=AE=E7=9B=98=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/js/chat-room/dialog.js | 18 ++++++++++++++++++ .../chat/partials/global-dialog.blade.php | 11 ----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/resources/js/chat-room/dialog.js b/resources/js/chat-room/dialog.js index 1a5b6dd..d5d555a 100644 --- a/resources/js/chat-room/dialog.js +++ b/resources/js/chat-room/dialog.js @@ -36,4 +36,22 @@ export function bindGlobalDialogControls() { window.chatDialog?._cancel?.(); } }); + + document.addEventListener("keydown", (event) => { + if (!(event.target instanceof HTMLTextAreaElement) || event.target.id !== "global-dialog-input") { + return; + } + + // prompt 输入框沿用旧体验:Enter 确认,Shift+Enter 保留换行,Esc 取消。 + if (event.key === "Enter" && !event.shiftKey) { + event.preventDefault(); + window.chatDialog?._confirm?.(); + return; + } + + if (event.key === "Escape") { + event.preventDefault(); + window.chatDialog?._cancel?.(); + } + }); } diff --git a/resources/views/chat/partials/global-dialog.blade.php b/resources/views/chat/partials/global-dialog.blade.php index 234522c..dd473ac 100644 --- a/resources/views/chat/partials/global-dialog.blade.php +++ b/resources/views/chat/partials/global-dialog.blade.php @@ -220,15 +220,4 @@ }, }; })(); - - // prompt 模式支持按 Enter 确认、Esc 取消 - document.getElementById('global-dialog-input').addEventListener('keydown', function(e) { - if (e.key === 'Enter' && !e.shiftKey) { - e.preventDefault(); - window.chatDialog._confirm(); - } else if (e.key === 'Escape') { - e.preventDefault(); - window.chatDialog._cancel(); - } - });