迁移管理菜单和钓鱼按钮事件绑定

This commit is contained in:
2026-04-25 04:03:13 +08:00
parent 54faf8b501
commit 4df557bb9e
6 changed files with 115 additions and 21 deletions
+8
View File
@@ -10,6 +10,8 @@ export { closeChatImageLightbox, initChatImageLightboxEvents, openChatImageLight
export { bindMobileDrawerControls } from "./chat-room/mobile-drawer.js";
export { bindToolbarControls } from "./chat-room/toolbar.js";
export { bindWelcomeMenuControls } from "./chat-room/welcome-menu.js";
export { bindAdminMenuControls } from "./chat-room/admin-menu.js";
export { bindFishingControls } from "./chat-room/fishing.js";
export {
BLOCKABLE_SYSTEM_SENDERS,
BLOCKED_SYSTEM_SENDERS_STORAGE_KEY,
@@ -44,6 +46,8 @@ import { closeChatImageLightbox, initChatImageLightboxEvents, openChatImageLight
import { bindMobileDrawerControls } from "./chat-room/mobile-drawer.js";
import { bindToolbarControls } from "./chat-room/toolbar.js";
import { bindWelcomeMenuControls } from "./chat-room/welcome-menu.js";
import { bindAdminMenuControls } from "./chat-room/admin-menu.js";
import { bindFishingControls } from "./chat-room/fishing.js";
import {
BLOCKABLE_SYSTEM_SENDERS,
BLOCKED_SYSTEM_SENDERS_STORAGE_KEY,
@@ -86,6 +90,8 @@ if (typeof window !== "undefined") {
bindMobileDrawerControls,
bindToolbarControls,
bindWelcomeMenuControls,
bindAdminMenuControls,
bindFishingControls,
CHAT_FONT_SIZE_STORAGE_KEY,
restoreChatFontSize,
closeChatImageLightbox,
@@ -127,6 +133,8 @@ if (typeof window !== "undefined") {
bindChatImageUploadControl();
bindFriendPanelControls();
bindToolbarControls();
bindAdminMenuControls();
bindFishingControls();
bindChatRightPanelControls();
bindMobileDrawerControls();
bindWelcomeMenuControls();
+59
View File
@@ -0,0 +1,59 @@
// 聊天室管理菜单事件绑定,替代 input-bar 中的管理类内联 onclick。
let adminMenuEventsBound = false;
/**
* 绑定管理菜单、管理动作与全屏特效选择事件。
*
* @returns {void}
*/
export function bindAdminMenuControls() {
if (adminMenuEventsBound || typeof document === "undefined") {
return;
}
adminMenuEventsBound = true;
document.addEventListener("click", (event) => {
if (!(event.target instanceof Element)) {
return;
}
const menuToggle = event.target.closest("[data-chat-admin-menu-toggle]");
if (menuToggle) {
event.preventDefault();
window.toggleAdminMenu?.(event);
return;
}
const adminAction = event.target.closest("[data-chat-admin-action]");
if (adminAction) {
event.preventDefault();
// 管理菜单只负责入口分发,权限校验和实际动作仍由后端与原有全局函数负责。
const action = adminAction.getAttribute("data-chat-admin-action") || "";
if (action && typeof window.runAdminAction === "function") {
window.runAdminAction(action);
}
return;
}
const effectButton = event.target.closest("[data-chat-admin-effect]");
if (effectButton) {
event.preventDefault();
// 特效按钮只触发管理员发起请求,实际播放仍由 chat:effect 广播和 EffectManager 处理。
const effect = effectButton.getAttribute("data-chat-admin-effect") || "";
if (effect && typeof window.selectEffect === "function") {
window.selectEffect(effect);
}
return;
}
if (event.target.closest("[data-chat-admin-menu]")) {
event.stopPropagation();
}
});
}
+28
View File
@@ -0,0 +1,28 @@
// 聊天室钓鱼入口事件绑定,先兼容存量全局 startFishing 实现。
let fishingEventsBound = false;
/**
* 绑定钓鱼按钮点击事件。
*
* @returns {void}
*/
export function bindFishingControls() {
if (fishingEventsBound || typeof document === "undefined") {
return;
}
fishingEventsBound = true;
document.addEventListener("click", (event) => {
if (!(event.target instanceof Element) || !event.target.closest("[data-chat-fishing-start]")) {
return;
}
event.preventDefault();
// 钓鱼完整流程仍在 fishing-panel.blade.php,当前模块只统一按钮事件入口。
if (typeof window.startFishing === "function") {
window.startFishing();
}
});
}