迁移右侧面板事件绑定

This commit is contained in:
2026-04-25 03:42:54 +08:00
parent 64a1e5d769
commit 10e9835530
3 changed files with 59 additions and 5 deletions
+4
View File
@@ -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();
}
+50
View File
@@ -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?.();
});
}