迁移手机抽屉工具按钮事件绑定
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -31,25 +31,24 @@
|
||||
<button class="mobile-drawer-close" data-mobile-drawer-close>✕</button>
|
||||
</div>
|
||||
<div class="mobile-drawer-body">
|
||||
<div class="mobile-tool-btn" onclick="closeMobileDrawer();quickDailySignIn();">✅<br>签到</div>
|
||||
<div class="mobile-tool-btn" onclick="closeMobileDrawer();openShopModal();">🛒<br>商店</div>
|
||||
<div class="mobile-tool-btn" onclick="closeMobileDrawer();openVipModal();">👑<br>会员</div>
|
||||
<div class="mobile-tool-btn" onclick="closeMobileDrawer();saveExp();">💾<br>存点</div>
|
||||
<div class="mobile-tool-btn" onclick="closeMobileDrawer();openGameHall();">🎮<br>娱乐</div>
|
||||
<div class="mobile-tool-btn" onclick="closeMobileDrawer();openBankModal();">🏦<br>银行</div>
|
||||
<div class="mobile-tool-btn" onclick="closeMobileDrawer();openMarriageStatusModal();">💍<br>婚姻</div>
|
||||
<div class="mobile-tool-btn" onclick="closeMobileDrawer();openFriendPanel();">👫<br>好友</div>
|
||||
<div class="mobile-tool-btn" onclick="closeMobileDrawer();openAvatarPicker();">🖼️<br>头像</div>
|
||||
<div class="mobile-tool-btn" onclick="closeMobileDrawer();document.getElementById('settings-modal').style.display='flex';">⚙️<br>设置</div>
|
||||
<div class="mobile-tool-btn" onclick="closeMobileDrawer();window.open('{{ route('feedback.index') }}','_blank');">📝<br>反馈</div>
|
||||
<div class="mobile-tool-btn" onclick="closeMobileDrawer();window.open('{{ route('guestbook.index') }}','_blank');">📬<br>留言</div>
|
||||
<div class="mobile-tool-btn" onclick="closeMobileDrawer();window.open('{{ route('guide') }}','_blank');">📖<br>规则</div>
|
||||
<div class="mobile-tool-btn" onclick="closeMobileDrawer();window.open('{{ route('leaderboard.index') }}','_blank');">🏆<br>排行</div>
|
||||
<div class="mobile-tool-btn" data-mobile-tool-action="daily-sign-in">✅<br>签到</div>
|
||||
<div class="mobile-tool-btn" data-mobile-tool-action="shop">🛒<br>商店</div>
|
||||
<div class="mobile-tool-btn" data-mobile-tool-action="vip">👑<br>会员</div>
|
||||
<div class="mobile-tool-btn" data-mobile-tool-action="save-exp">💾<br>存点</div>
|
||||
<div class="mobile-tool-btn" data-mobile-tool-action="game">🎮<br>娱乐</div>
|
||||
<div class="mobile-tool-btn" data-mobile-tool-action="bank">🏦<br>银行</div>
|
||||
<div class="mobile-tool-btn" data-mobile-tool-action="marriage">💍<br>婚姻</div>
|
||||
<div class="mobile-tool-btn" data-mobile-tool-action="friend">👫<br>好友</div>
|
||||
<div class="mobile-tool-btn" data-mobile-tool-action="avatar">🖼️<br>头像</div>
|
||||
<div class="mobile-tool-btn" data-mobile-tool-action="settings">⚙️<br>设置</div>
|
||||
<div class="mobile-tool-btn" data-mobile-tool-url="{{ route('feedback.index') }}">📝<br>反馈</div>
|
||||
<div class="mobile-tool-btn" data-mobile-tool-url="{{ route('guestbook.index') }}">📬<br>留言</div>
|
||||
<div class="mobile-tool-btn" data-mobile-tool-url="{{ route('guide') }}">📖<br>规则</div>
|
||||
<div class="mobile-tool-btn" data-mobile-tool-url="{{ route('leaderboard.index') }}">🏆<br>排行</div>
|
||||
@if ($user->id === 1 || $user->activePosition()->exists())
|
||||
<div class="mobile-tool-btn" style="color:#ffcc00;" onclick="closeMobileDrawer();window.open('/admin','_blank');">🛡️<br>管理</div>
|
||||
<div class="mobile-tool-btn" style="color:#ffcc00;" data-mobile-tool-url="/admin">🛡️<br>管理</div>
|
||||
@endif
|
||||
<div class="mobile-tool-btn" style="color:#ffaaaa;"
|
||||
onclick="closeMobileDrawer();window.chatDialog.confirm('确定要离开聊天室吗?','离开聊天室').then(ok=>{if(ok)leaveRoom();});">🚪<br>离开</div>
|
||||
<div class="mobile-tool-btn" style="color:#ffaaaa;" data-mobile-tool-action="leave">🚪<br>离开</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user