迁移五子棋邀请按钮事件

This commit is contained in:
2026-04-25 11:05:15 +08:00
parent 6cb63a98e2
commit ed484c9235
3 changed files with 65 additions and 9 deletions
@@ -3020,27 +3020,27 @@
div.style.cssText =
'background:linear-gradient(135deg,#e8eef8,#f0f4fc); ' +
'border-left:3px solid #336699; border-radius:4px; padding:6px 10px; margin:3px 0;';
const safeInviterName = escapeHtml(e.inviter_name);
const gomokuGameId = Number.parseInt(e.game_id, 10) || 0;
const acceptBtn = isSelf ?
// 自己的邀请:只显示打开面板按钮,方便被关掉后重新进入
`<button onclick="document.querySelector('[x-data=\"gomokuPanel()\"]').__x.$data.open()"
// 自己的邀请:只显示打开面板按钮,点击事件交给 Vite game-panels.js 委托。
`<button type="button" data-gomoku-open-panel class="gomoku-invite-open"
style="margin-left:10px; padding:3px 12px; border:1.5px solid #2d6096;
border-radius:12px; background:#f0f6ff; color:#2d6096; font-size:12px;
cursor:pointer; font-family:inherit; transition:all .15s;"
onmouseover="this.style.background='#ddeeff'" onmouseout="this.style.background='#f0f6ff'">
cursor:pointer; font-family:inherit; transition:all .15s;">
⤴️ 打开面板
</button>` :
// 别人的邀请:显示接受挑战按钮
`<button onclick="acceptGomokuInvite(${e.game_id})" id="gomoku-accept-${e.game_id}"
// 别人的邀请:显示接受挑战按钮,业务仍复用五子棋面板的 acceptGomokuInvite。
`<button type="button" data-gomoku-accept-id="${gomokuGameId}" id="gomoku-accept-${gomokuGameId}" class="gomoku-invite-accept"
style="margin-left:10px; padding:3px 12px; border:1.5px solid #336699;
border-radius:12px; background:#336699; color:#fff; font-size:12px;
cursor:pointer; font-family:inherit; transition:all .15s;"
onmouseover="this.style.opacity='.8'" onmouseout="this.style.opacity='1'">
cursor:pointer; font-family:inherit; transition:opacity .15s;">
⚔️ 接受挑战
</button>`;
div.innerHTML = `<span style="color:#1e3a5f; font-weight:bold;">
♟️ 【五子棋】<b>${e.inviter_name}</b> 发起了随机对战!${isSelf ? '(等待中)' : ''}
♟️ 【五子棋】<b>${safeInviterName}</b> 发起了随机对战!${isSelf ? '(等待中)' : ''}
</span>${acceptBtn}
<span class="msg-time">(${timeStr})</span>`;