From 10e9835530af717cc82539ab787056a7a489d65c Mon Sep 17 00:00:00 2001 From: lkddi Date: Sat, 25 Apr 2026 03:42:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=8F=B3=E4=BE=A7=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E4=BA=8B=E4=BB=B6=E7=BB=91=E5=AE=9A?= 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/right-panel.js | 50 +++++++++++++++++++ .../partials/layout/right-panel.blade.php | 10 ++-- 3 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 resources/js/chat-room/right-panel.js diff --git a/resources/js/chat-room.js b/resources/js/chat-room.js index 31c146b..bf4c789 100644 --- a/resources/js/chat-room.js +++ b/resources/js/chat-room.js @@ -18,6 +18,7 @@ export { setSoundMuted, shouldMigrateLocalChatPreferences, } from "./chat-room/preferences-status.js"; +export { bindChatRightPanelControls } from "./chat-room/right-panel.js"; export { normalizeRoomStatus, renderRoomStatusRow, @@ -45,6 +46,7 @@ import { setSoundMuted, shouldMigrateLocalChatPreferences, } from "./chat-room/preferences-status.js"; +import { bindChatRightPanelControls } from "./chat-room/right-panel.js"; import { normalizeRoomStatus, renderRoomStatusRow, @@ -78,6 +80,7 @@ if (typeof window !== "undefined") { persistBlockedSystemSenders, setSoundMuted, shouldMigrateLocalChatPreferences, + bindChatRightPanelControls, normalizeRoomStatus, renderRoomStatusRow, renderRoomsOnlineStatus, @@ -91,4 +94,5 @@ if (typeof window !== "undefined") { window.applyFontSize = applyFontSize; bindChatFontSizeControl(); bindChatImageUploadControl(); + bindChatRightPanelControls(); } diff --git a/resources/js/chat-room/right-panel.js b/resources/js/chat-room/right-panel.js new file mode 100644 index 0000000..1806a74 --- /dev/null +++ b/resources/js/chat-room/right-panel.js @@ -0,0 +1,50 @@ +// 聊天室右侧名单/房间面板事件绑定,逐步替代 Blade 内联事件。 + +let rightPanelEventsBound = false; + +/** + * 绑定右侧在线面板的 tab、刷新、排序和搜索事件。 + * + * @returns {void} + */ +export function bindChatRightPanelControls() { + if (rightPanelEventsBound || typeof document === "undefined") { + return; + } + + rightPanelEventsBound = true; + document.addEventListener("click", (event) => { + if (!(event.target instanceof Element)) { + return; + } + + const tabButton = event.target.closest("[data-chat-right-tab]"); + if (tabButton) { + event.preventDefault(); + window.switchTab?.(tabButton.dataset.chatRightTab); + return; + } + + const refreshButton = event.target.closest("[data-chat-user-list-refresh]"); + if (refreshButton) { + event.preventDefault(); + window.renderUserList?.(); + } + }); + + document.addEventListener("change", (event) => { + if (!(event.target instanceof HTMLSelectElement) || event.target.id !== "user-sort-select") { + return; + } + + window.renderUserList?.(); + }); + + document.addEventListener("input", (event) => { + if (!(event.target instanceof HTMLInputElement) || event.target.id !== "user-search-input") { + return; + } + + window.scheduleFilterUserList?.(); + }); +} diff --git a/resources/views/chat/partials/layout/right-panel.blade.php b/resources/views/chat/partials/layout/right-panel.blade.php index 7ffa8e2..32babf5 100644 --- a/resources/views/chat/partials/layout/right-panel.blade.php +++ b/resources/views/chat/partials/layout/right-panel.blade.php @@ -8,8 +8,8 @@
{{-- Tab 标题栏 --}}
- - + +
{{-- 用户列表面板 --}} @@ -20,7 +20,7 @@
人气:{{ $room->visit_num ?? 0 }}
0人 - 刷新
@@ -29,7 +29,7 @@
排序: -
-