From 21a727a69310b85e634d8fb8ac1c0ebcce5b467e Mon Sep 17 00:00:00 2001 From: lkddi Date: Sat, 25 Apr 2026 10:41:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E8=81=8A=E5=A4=A9=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E6=8F=90=E4=BA=A4=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.js | 4 +++ resources/js/chat-room/composer.js | 29 +++++++++++++++++++ .../chat/partials/layout/input-bar.blade.php | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 resources/js/chat-room/composer.js diff --git a/resources/js/chat-room.js b/resources/js/chat-room.js index 7bcbf07..3c8ef9a 100644 --- a/resources/js/chat-room.js +++ b/resources/js/chat-room.js @@ -6,6 +6,7 @@ export { bindGlobalDialogControls } from "./chat-room/dialog.js"; export { bindDailySignInControls } from "./chat-room/daily-sign-in.js"; export { applyFontSize, bindChatFontSizeControl, CHAT_FONT_SIZE_STORAGE_KEY, restoreChatFontSize } from "./chat-room/font-size.js"; export { bindChatImageUploadControl } from "./chat-room/image-upload.js"; +export { bindChatComposerControls } from "./chat-room/composer.js"; export { bindFriendPanelControls, closeFriendPanel, friendSearch, loadFriends, openFriendPanel, quickFriendAction } from "./chat-room/friend-panel.js"; export { closeChatImageLightbox, initChatImageLightboxEvents, openChatImageLightbox } from "./chat-room/lightbox.js"; export { @@ -76,6 +77,7 @@ import { bindGlobalDialogControls } from "./chat-room/dialog.js"; import { bindDailySignInControls } from "./chat-room/daily-sign-in.js"; import { applyFontSize, bindChatFontSizeControl, CHAT_FONT_SIZE_STORAGE_KEY, restoreChatFontSize } from "./chat-room/font-size.js"; import { bindChatImageUploadControl } from "./chat-room/image-upload.js"; +import { bindChatComposerControls } from "./chat-room/composer.js"; import { bindFriendPanelControls, closeFriendPanel, friendSearch, loadFriends, openFriendPanel, quickFriendAction } from "./chat-room/friend-panel.js"; import { closeChatImageLightbox, initChatImageLightboxEvents, openChatImageLightbox } from "./chat-room/lightbox.js"; import { @@ -151,6 +153,7 @@ if (typeof window !== "undefined") { applyFontSize, bindChatFontSizeControl, bindChatImageUploadControl, + bindChatComposerControls, bindFriendPanelControls, closeFriendPanel, friendSearch, @@ -253,6 +256,7 @@ if (typeof window !== "undefined") { bindDailySignInControls(); bindChatFontSizeControl(); bindChatImageUploadControl(); + bindChatComposerControls(); bindFriendPanelControls(); bindToolbarControls(); bindAdminMenuControls(); diff --git a/resources/js/chat-room/composer.js b/resources/js/chat-room/composer.js new file mode 100644 index 0000000..a38d7b7 --- /dev/null +++ b/resources/js/chat-room/composer.js @@ -0,0 +1,29 @@ +// 聊天输入区事件绑定,逐步替代底部输入栏内联提交事件。 + +let chatComposerEventsBound = false; + +/** + * 绑定聊天表单提交事件。 + * 发送主流程仍由 Blade 主脚本的 sendMessage 维护,这里只统一 submit 入口。 + * + * @returns {void} + */ +export function bindChatComposerControls() { + if (chatComposerEventsBound || typeof document === "undefined") { + return; + } + + chatComposerEventsBound = true; + document.addEventListener("submit", (event) => { + const form = event.target; + if (!(form instanceof HTMLFormElement) || !form.matches("[data-chat-form]")) { + return; + } + + event.preventDefault(); + + if (typeof window.sendMessage === "function") { + void window.sendMessage(event); + } + }); +} diff --git a/resources/views/chat/partials/layout/input-bar.blade.php b/resources/views/chat/partials/layout/input-bar.blade.php index 1a3c6fb..80dafb8 100644 --- a/resources/views/chat/partials/layout/input-bar.blade.php +++ b/resources/views/chat/partials/layout/input-bar.blade.php @@ -19,7 +19,7 @@ @endphp
-
+ {{-- 第一行:工具选项 --}}