迁移五子棋邀请按钮事件
This commit is contained in:
@@ -27,6 +27,39 @@ function closeAlpineGamePanel(panelId) {
|
||||
panelData.show = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开五子棋面板,作为公屏邀请按钮和存量全局函数之间的桥接。
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function openGomokuPanelFromInvite() {
|
||||
if (typeof window.openGomokuPanel === "function") {
|
||||
window.openGomokuPanel();
|
||||
return;
|
||||
}
|
||||
|
||||
const panel = document.getElementById("gomoku-panel");
|
||||
const panelData = panel && typeof window.Alpine?.$data === "function"
|
||||
? window.Alpine.$data(panel)
|
||||
: null;
|
||||
|
||||
panelData?.open?.();
|
||||
}
|
||||
|
||||
/**
|
||||
* 接受五子棋公屏邀请,业务仍沿用五子棋面板里的存量全局函数。
|
||||
*
|
||||
* @param {string} gameId 对局 ID
|
||||
* @returns {void}
|
||||
*/
|
||||
function acceptGomokuInviteFromMessage(gameId) {
|
||||
if (!gameId) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.acceptGomokuInvite?.(gameId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定小型游戏面板通用关闭事件。
|
||||
*
|
||||
@@ -43,6 +76,20 @@ export function bindGamePanelControls() {
|
||||
return;
|
||||
}
|
||||
|
||||
const gomokuOpenButton = event.target.closest("[data-gomoku-open-panel]");
|
||||
if (gomokuOpenButton) {
|
||||
event.preventDefault();
|
||||
openGomokuPanelFromInvite();
|
||||
return;
|
||||
}
|
||||
|
||||
const gomokuAcceptButton = event.target.closest("[data-gomoku-accept-id]");
|
||||
if (gomokuAcceptButton) {
|
||||
event.preventDefault();
|
||||
acceptGomokuInviteFromMessage(gomokuAcceptButton.getAttribute("data-gomoku-accept-id") || "");
|
||||
return;
|
||||
}
|
||||
|
||||
const closeButton = event.target.closest("[data-game-panel-close]");
|
||||
if (!closeButton) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user