迁移游戏面板关闭事件
This commit is contained in:
@@ -33,6 +33,7 @@ export {
|
||||
} from "./chat-room/baccarat-loss-cover-admin.js";
|
||||
export { bindBaccaratLossCoverControls } from "./chat-room/baccarat-loss-cover.js";
|
||||
export { bindGameHallControls } from "./chat-room/game-hall.js";
|
||||
export { bindGamePanelControls } from "./chat-room/game-panels.js";
|
||||
export {
|
||||
bankAction,
|
||||
bankLoadInfo,
|
||||
@@ -106,6 +107,7 @@ import {
|
||||
} from "./chat-room/baccarat-loss-cover-admin.js";
|
||||
import { bindBaccaratLossCoverControls } from "./chat-room/baccarat-loss-cover.js";
|
||||
import { bindGameHallControls } from "./chat-room/game-hall.js";
|
||||
import { bindGamePanelControls } from "./chat-room/game-panels.js";
|
||||
import {
|
||||
bankAction,
|
||||
bankLoadInfo,
|
||||
@@ -182,6 +184,7 @@ if (typeof window !== "undefined") {
|
||||
closeCurrentBaccaratLossCoverEvent,
|
||||
bindBaccaratLossCoverControls,
|
||||
bindGameHallControls,
|
||||
bindGamePanelControls,
|
||||
loadAdminCurrentLossCoverEvent,
|
||||
openAdminBaccaratLossCoverModal,
|
||||
submitBaccaratLossCoverEvent,
|
||||
@@ -269,6 +272,7 @@ if (typeof window !== "undefined") {
|
||||
bindBaccaratLossCoverAdminControls();
|
||||
bindBaccaratLossCoverControls();
|
||||
bindGameHallControls();
|
||||
bindGamePanelControls();
|
||||
bindBankControls();
|
||||
bindFishingControls();
|
||||
bindMarriageStatusControls();
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
// 小型游戏弹窗通用事件代理,收口各游戏头部关闭按钮内联 onclick。
|
||||
|
||||
let gamePanelEventsBound = false;
|
||||
|
||||
/**
|
||||
* 关闭指定 Alpine 游戏面板。
|
||||
*
|
||||
* @param {string} panelId 面板 DOM ID
|
||||
* @returns {void}
|
||||
*/
|
||||
function closeAlpineGamePanel(panelId) {
|
||||
const panel = document.getElementById(panelId);
|
||||
const panelData = panel && typeof window.Alpine?.$data === "function"
|
||||
? window.Alpine.$data(panel)
|
||||
: null;
|
||||
|
||||
if (!panelData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 多数游戏面板提供 close(),占卜面板只暴露 show 状态,因此保留 show=false 兜底。
|
||||
if (typeof panelData.close === "function") {
|
||||
panelData.close();
|
||||
return;
|
||||
}
|
||||
|
||||
panelData.show = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定小型游戏面板通用关闭事件。
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
export function bindGamePanelControls() {
|
||||
if (gamePanelEventsBound || typeof document === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
gamePanelEventsBound = true;
|
||||
document.addEventListener("click", (event) => {
|
||||
if (!(event.target instanceof Element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const closeButton = event.target.closest("[data-game-panel-close]");
|
||||
if (!closeButton) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
closeAlpineGamePanel(closeButton.getAttribute("data-game-panel-close") || "");
|
||||
});
|
||||
}
|
||||
@@ -27,7 +27,7 @@
|
||||
<div style="font-size:11px; color:rgba(255,255,255,.75);">
|
||||
今日免费 <span x-text="freeCount"></span> 次,已用 <span x-text="freeUsed"></span> 次
|
||||
</div>
|
||||
<span onclick="Alpine.$data(document.getElementById('fortune-panel')).show = false"
|
||||
<span data-game-panel-close="fortune-panel"
|
||||
style="cursor:pointer; font-size:18px; color:rgba(255,255,255,.8); line-height:1; transition:opacity .15s;"
|
||||
onmouseover="this.style.opacity=1" onmouseout="this.style.opacity=.8">×</span>
|
||||
</div>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
{{-- 结算 --}}
|
||||
<div x-show="phase === 'settled'" style="display:none;"
|
||||
style="font-size:12px; color:#ffe082; font-weight:bold;">🏆 已结算</div>
|
||||
<span onclick="Alpine.$data(document.getElementById('horse-race-panel')).close()"
|
||||
<span data-game-panel-close="horse-race-panel"
|
||||
style="cursor:pointer; font-size:18px; color:rgba(255,255,255,.8); line-height:1; transition:opacity .15s;"
|
||||
onmouseover="this.style.opacity=1" onmouseout="this.style.opacity=.8">×</span>
|
||||
</div>
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<div x-show="dailyLimit > 0"
|
||||
style="font-size:11px; color:rgba(255,255,255,.7); background:rgba(255,255,255,.15); padding:2px 8px; border-radius:10px;"
|
||||
x-text="'剩余 ' + remaining + ' 次'"></div>
|
||||
<span onclick="Alpine.$data(document.getElementById('slot-panel')).close()"
|
||||
<span data-game-panel-close="slot-panel"
|
||||
style="cursor:pointer; font-size:18px; color:rgba(255,255,255,.8); line-height:1; transition:opacity .15s;"
|
||||
onmouseover="this.style.opacity=1" onmouseout="this.style.opacity=.8">×</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user