fix: 代码审查问题修复 — socket 代理提供 + inject 空安全 + 观战人数响应式

This commit is contained in:
2026-06-23 11:28:27 +08:00
parent cf1a14bf24
commit f937b5cdb3
6 changed files with 54 additions and 21 deletions
+10 -2
View File
@@ -52,6 +52,9 @@ export const useRoomStore = defineStore('room', () => {
const drawRequested = ref<boolean>(false)
const drawRequestFrom = ref<string | null>(null)
// ===== 观战者 =====
const spectatorCount = ref<number>(0)
/**
* 从房间详情 HTTP 响应初始化 Store
* @param detail - 房间详情响应数据
@@ -129,6 +132,11 @@ export const useRoomStore = defineStore('room', () => {
resultType.value = type
}
/** 更新观战人数 */
function setSpectatorCount(count: number) {
spectatorCount.value = count
}
/** 重置状态 */
function reset() {
roomId.value = ''
@@ -150,8 +158,8 @@ export const useRoomStore = defineStore('room', () => {
boardState, currentTurn, moves, winner, resultType,
isPlaying, isFinished,
messages,
drawRequested, drawRequestFrom,
drawRequested, drawRequestFrom, spectatorCount,
initFromDetail, applyMove, setCurrentTurn, addMessage,
updateReady, addPlayer, removePlayer, setGameOver, reset
updateReady, addPlayer, removePlayer, setGameOver, setSpectatorCount, reset
}
})