diff --git a/resources/js/chat-room/dialog.js b/resources/js/chat-room/dialog.js index 63b4284..341cc98 100644 --- a/resources/js/chat-room/dialog.js +++ b/resources/js/chat-room/dialog.js @@ -239,4 +239,18 @@ export function bindGlobalDialogControls() { window.chatDialog?._cancel?.(); } }); + + // 点击遮罩层(弹窗外部)关闭弹窗 + document.addEventListener("click", (event) => { + const modal = document.getElementById("global-dialog-modal"); + if (!modal || modal.style.display === "none") return; + if (event.target === modal) { + // alert 模式直接隐藏,confirm/prompt 视为取消 + if (currentDialogType === "alert") { + window.chatDialog?._hide?.(); + } else { + window.chatDialog?._cancel?.(); + } + } + }); }