迁移五子棋外部入口脚本
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
* - game-hall.js:处理娱乐大厅弹窗和游戏入口卡片。
|
||||
* - game-bootstrap.js:提供非关键游戏延迟初始化工具。
|
||||
* - game-panels.js:处理通用游戏面板关闭事件。
|
||||
* - gomoku-controls.js:处理五子棋外部打开和接受邀请入口。
|
||||
* - horse-race-fab.js:处理赛马竞猜悬浮按钮拖动与打开面板。
|
||||
* - holiday-modal.js:处理节日福利弹窗、广播监听、领取状态和系统消息入口。
|
||||
* - initial-state.js:恢复首屏历史消息、欢迎消息、入场特效和挂起婚姻事件。
|
||||
@@ -107,6 +108,7 @@ export {
|
||||
export { bindGameHallControls, closeGameHall, openGameHall } from "./chat-room/game-hall.js";
|
||||
export { bindGameBootstrapControls, deferChatGameBootstrap } from "./chat-room/game-bootstrap.js";
|
||||
export { bindGamePanelControls } from "./chat-room/game-panels.js";
|
||||
export { acceptGomokuInvite, bindGomokuControls, openGomokuPanel } from "./chat-room/gomoku-controls.js";
|
||||
export { bindHorseRaceFabControls, horseRaceFab } from "./chat-room/horse-race-fab.js";
|
||||
export {
|
||||
bindHolidayModalControls,
|
||||
@@ -252,6 +254,7 @@ import {
|
||||
import { bindGameHallControls, closeGameHall, openGameHall } from "./chat-room/game-hall.js";
|
||||
import { bindGameBootstrapControls, deferChatGameBootstrap } from "./chat-room/game-bootstrap.js";
|
||||
import { bindGamePanelControls } from "./chat-room/game-panels.js";
|
||||
import { acceptGomokuInvite, bindGomokuControls, openGomokuPanel } from "./chat-room/gomoku-controls.js";
|
||||
import { bindHorseRaceFabControls, horseRaceFab } from "./chat-room/horse-race-fab.js";
|
||||
import {
|
||||
bindHolidayModalControls,
|
||||
@@ -404,6 +407,9 @@ if (typeof window !== "undefined") {
|
||||
bindGameBootstrapControls,
|
||||
deferChatGameBootstrap,
|
||||
bindGamePanelControls,
|
||||
acceptGomokuInvite,
|
||||
bindGomokuControls,
|
||||
openGomokuPanel,
|
||||
bindHorseRaceFabControls,
|
||||
horseRaceFab,
|
||||
bindHolidayModalControls,
|
||||
@@ -564,6 +570,8 @@ if (typeof window !== "undefined") {
|
||||
window.deferChatGameBootstrap = deferChatGameBootstrap;
|
||||
window.lotteryPanel = lotteryPanel;
|
||||
window.openGameHall = openGameHall;
|
||||
window.acceptGomokuInvite = acceptGomokuInvite;
|
||||
window.openGomokuPanel = openGomokuPanel;
|
||||
window.horseRaceFab = horseRaceFab;
|
||||
window.openLotteryPanel = openLotteryPanel;
|
||||
window.openBankModal = openBankModal;
|
||||
@@ -644,6 +652,7 @@ if (typeof window !== "undefined") {
|
||||
bindGameHallControls();
|
||||
bindGameBootstrapControls();
|
||||
bindGamePanelControls();
|
||||
bindGomokuControls();
|
||||
bindHorseRaceFabControls();
|
||||
bindHolidayModalControls();
|
||||
bindChatInitialStateControls();
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
// 五子棋外部入口控制,负责从工具栏或邀请消息打开棋盘。
|
||||
|
||||
/**
|
||||
* 读取五子棋面板 Alpine 状态。
|
||||
*
|
||||
* @returns {Record<string, any>|null}
|
||||
*/
|
||||
function getGomokuPanelState() {
|
||||
const panel = document.getElementById("gomoku-panel");
|
||||
|
||||
if (!panel || typeof window.Alpine?.$data !== "function") {
|
||||
return null;
|
||||
}
|
||||
|
||||
return window.Alpine.$data(panel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从外部打开五子棋面板。
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
export function openGomokuPanel() {
|
||||
getGomokuPanelState()?.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* 接受 PvP 邀请并打开棋盘。
|
||||
*
|
||||
* @param {number|string} gameId 对局 ID
|
||||
* @returns {void}
|
||||
*/
|
||||
export function acceptGomokuInvite(gameId) {
|
||||
getGomokuPanelState()?.openAndJoin(gameId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂载五子棋全局入口,兼容广播监听和存量 Blade 调用。
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
export function bindGomokuControls() {
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
window.openGomokuPanel = openGomokuPanel;
|
||||
window.acceptGomokuInvite = acceptGomokuInvite;
|
||||
}
|
||||
@@ -938,15 +938,5 @@
|
||||
};
|
||||
}
|
||||
|
||||
/** 从外部打开五子棋面板 */
|
||||
window.openGomokuPanel = function() {
|
||||
const panel = document.getElementById('gomoku-panel');
|
||||
if (panel) Alpine.$data(panel).open();
|
||||
};
|
||||
|
||||
/** 接受 PvP 邀请并打开棋盘 */
|
||||
window.acceptGomokuInvite = function(gameId) {
|
||||
const panel = document.getElementById('gomoku-panel');
|
||||
if (panel) Alpine.$data(panel).openAndJoin(gameId);
|
||||
};
|
||||
{{-- 五子棋外部打开入口已迁移到 resources/js/chat-room/gomoku-controls.js --}}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user