diff --git a/resources/js/chat-room/mobile-drawer.js b/resources/js/chat-room/mobile-drawer.js index d13fa7c..4f3f187 100644 --- a/resources/js/chat-room/mobile-drawer.js +++ b/resources/js/chat-room/mobile-drawer.js @@ -2,6 +2,56 @@ let mobileDrawerEventsBound = false; +/** + * 执行手机抽屉工具入口动作。 + * + * @param {string} action 工具动作 + * @returns {void} + */ +function runMobileToolAction(action) { + // 抽屉工具只负责分发到现有全局函数,业务实现仍留在原模块中。 + const actions = { + "daily-sign-in": () => window.quickDailySignIn?.(), + shop: () => window.openShopModal?.(), + vip: () => window.openVipModal?.(), + "save-exp": () => window.saveExp?.(), + game: () => window.openGameHall?.(), + bank: () => window.openBankModal?.(), + marriage: () => window.openMarriageStatusModal?.(), + friend: () => window.openFriendPanel?.(), + avatar: () => window.openAvatarPicker?.(), + settings: () => { + if (typeof window.openSettingsModal === "function") { + window.openSettingsModal(); + return; + } + + const settingsModal = document.getElementById("settings-modal"); + if (settingsModal) { + settingsModal.style.display = "flex"; + } + }, + }; + + actions[action]?.(); +} + +/** + * 确认并执行手机端离开房间动作。 + * + * @returns {void} + */ +function confirmMobileLeaveRoom() { + // 离开房间需要保留二次确认,避免手机误触直接退出。 + window.chatDialog + ?.confirm("确定要离开聊天室吗?", "离开聊天室") + .then((ok) => { + if (ok) { + window.leaveRoom?.(); + } + }); +} + /** * 绑定手机端抽屉基础控件事件。 * @@ -31,6 +81,34 @@ export function bindMobileDrawerControls() { return; } + const toolAction = event.target.closest("[data-mobile-tool-action]"); + if (toolAction) { + event.preventDefault(); + window.closeMobileDrawer?.(); + + const action = toolAction.getAttribute("data-mobile-tool-action") || ""; + if (action === "leave") { + confirmMobileLeaveRoom(); + return; + } + + runMobileToolAction(action); + return; + } + + const toolUrl = event.target.closest("[data-mobile-tool-url]"); + if (toolUrl) { + event.preventDefault(); + window.closeMobileDrawer?.(); + + const url = toolUrl.getAttribute("data-mobile-tool-url"); + if (url) { + window.open(url, "_blank"); + } + + return; + } + const tabTrigger = event.target.closest("[data-mobile-drawer-tab]"); if (tabTrigger) { event.preventDefault(); diff --git a/resources/views/chat/partials/layout/mobile-drawer.blade.php b/resources/views/chat/partials/layout/mobile-drawer.blade.php index f900140..8fd363d 100644 --- a/resources/views/chat/partials/layout/mobile-drawer.blade.php +++ b/resources/views/chat/partials/layout/mobile-drawer.blade.php @@ -31,25 +31,24 @@
-

签到
-
🛒
商店
-
👑
会员
-
💾
存点
-
🎮
娱乐
-
🏦
银行
-
💍
婚姻
-
👫
好友
-
🖼️
头像
-
⚙️
设置
-
📝
反馈
-
📬
留言
-
📖
规则
-
🏆
排行
+

签到
+
🛒
商店
+
👑
会员
+
💾
存点
+
🎮
娱乐
+
🏦
银行
+
💍
婚姻
+
👫
好友
+
🖼️
头像
+
⚙️
设置
+
📝
反馈
+
📬
留言
+
📖
规则
+
🏆
排行
@if ($user->id === 1 || $user->activePosition()->exists()) -
🛡️
管理
+
🛡️
管理
@endif -
🚪
离开
+
🚪
离开