feat: v1.2.0 房间详情/聊天/踢人 + 速率限制 + WebSocket增强

Server:
- API速率限制中间件 (120 req/min per IP, X-RateLimit headers)
- 房间聊天API: POST /rooms/:id/chat
- 认证中间件放行公开GET路由和房间join
- WebSocket: 房间订阅/取消订阅 (subscribe/unsubscribe)
- WebSocket: 房间聊天广播 (chat -> broadcastToRoom)
- WebSocket: 房间事件通知 (roomCreated/Deleted/playerJoined/Left)

Client:
- 房间详情弹窗: 点击房间卡片打开
  - 房间信息网格 (房间号/房主/版本/人数)
  - 在线玩家列表 (5秒自动刷新)
  - 踢出玩家 (确认对话框)
  - 房间聊天 (实时发送/显示)
  - 加入房间 / 删除房间按钮
- 连接状态指示器动画 (online/offline/connecting)
- 房间卡片hover效果
- 版本更新到 v1.2.0
- ApiClient: 新增 getRoomDetail/kickPlayer/sendChat
- Preload: 新增对应IPC方法
- Main: 新增 rooms:detail/kick/chat handlers
This commit is contained in:
FunMC
2026-02-23 08:21:09 +08:00
parent 7fdc570391
commit 80fe5e6e6e
8 changed files with 415 additions and 5 deletions

View File

@@ -471,6 +471,94 @@ select.input { cursor: pointer; }
.recent-list-item .url { flex: 1; }
.recent-list-empty { font-size: 12px; color: #555; padding: 8px 0; }
/* Modal */
.modal-overlay {
position: fixed; top: 0; left: 0; right: 0; bottom: 0;
background: rgba(0,0,0,0.6); z-index: 1000;
display: flex; align-items: center; justify-content: center;
backdrop-filter: blur(4px);
}
.modal {
background: var(--bg-card); border: 1px solid var(--border);
border-radius: 14px; width: 520px; max-height: 80vh;
display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.modal-header {
display: flex; justify-content: space-between; align-items: center;
padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; color: var(--text); margin: 0; }
.modal-close {
background: none; border: none; color: var(--text-dim); font-size: 22px;
cursor: pointer; padding: 0 4px; line-height: 1;
}
.modal-close:hover { color: var(--red); }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-info {
display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px;
}
.modal-info-item {
background: var(--bg-dark); border-radius: 8px; padding: 8px 12px;
}
.modal-info-item .label { font-size: 10px; color: var(--text-dim); margin-bottom: 2px; }
.modal-info-item .value { font-size: 13px; color: var(--text); font-weight: 600; }
.modal-section { margin-top: 16px; }
.modal-section h4 { font-size: 13px; color: var(--green); margin-bottom: 8px; }
.modal-footer {
display: flex; gap: 8px; padding: 12px 20px;
border-top: 1px solid var(--border); justify-content: flex-end;
}
/* Player List */
.player-list { display: flex; flex-direction: column; gap: 4px; }
.player-item {
display: flex; justify-content: space-between; align-items: center;
background: var(--bg-dark); border-radius: 6px; padding: 8px 12px;
}
.player-item .player-name { font-size: 13px; color: var(--text); }
.player-item .player-time { font-size: 10px; color: var(--text-dim); }
.player-item .btn-kick {
background: rgba(233,69,96,0.15); border: none; color: var(--red);
padding: 3px 10px; border-radius: 4px; font-size: 11px; cursor: pointer;
}
.player-item .btn-kick:hover { background: rgba(233,69,96,0.3); }
.player-empty { font-size: 12px; color: #555; padding: 12px 0; text-align: center; }
/* Chat */
.chat-messages {
background: var(--bg-dark); border-radius: 8px;
height: 160px; overflow-y: auto; padding: 8px 12px;
display: flex; flex-direction: column; gap: 4px;
margin-bottom: 8px;
}
.chat-msg {
font-size: 12px; line-height: 1.4;
}
.chat-msg .chat-sender { color: var(--green); font-weight: 600; }
.chat-msg .chat-text { color: var(--text-dim); }
.chat-msg .chat-time { color: #555; font-size: 10px; margin-left: 6px; }
.chat-msg.system { color: #888; font-style: italic; }
.chat-input-row { display: flex; gap: 6px; }
.chat-input-row .input { flex: 1; padding: 8px 10px; font-size: 12px; }
.btn-sm { padding: 6px 14px !important; font-size: 12px !important; }
/* Connection status indicator */
.sidebar-status {
display: flex; align-items: center; gap: 6px;
padding: 8px 16px; font-size: 11px;
}
.status-dot {
width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: #555; }
.status-dot.connecting { background: #ff9800; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
/* Room card clickable */
.room-card { cursor: pointer; transition: border-color 0.2s, transform 0.1s; }
.room-card:hover { border-color: var(--green); transform: translateY(-1px); }
/* Utility */
.hidden { display: none !important; }