diff --git a/src/desktop/components/ChatBoard.vue b/src/desktop/components/ChatBoard.vue index e43c609..f2b6583 100644 --- a/src/desktop/components/ChatBoard.vue +++ b/src/desktop/components/ChatBoard.vue @@ -7,15 +7,15 @@ v-for="(item, index) in messages" :key="index" :size="6" - :justify="userId === item.userId ? 'end' : 'start'" + :justify=" (user.userInfo?.id || '') === item.userId ? 'end' : 'start'" > - + {{ item.nickname }} @@ -25,7 +25,7 @@ @@ -72,7 +72,6 @@ const props = defineProps() const gameHub = useGameHubStore() const user = useUserStore() -const userId = user.userInfo?.id || '' const messages = ref([]) const inputMessage = ref('') const chatBoard = ref() diff --git a/src/desktop/views/room/JoinRoom.vue b/src/desktop/views/room/JoinRoom.vue index 95bde14..c207013 100644 --- a/src/desktop/views/room/JoinRoom.vue +++ b/src/desktop/views/room/JoinRoom.vue @@ -51,6 +51,10 @@ async function initJoinRoom() { gameHub.addGameHubListener('PlayerJoined', gameJoinListener) //JoinRoom是在主界面的 + + //TODO 此处一定不会有user.currentRoomId + //需要从服务器获取! + //能走到这里,那么服务器已经连上了 if (user.currentRoomId) { // 重连检查 diff --git a/src/desktop/views/room/WaitingRoomBase.vue b/src/desktop/views/room/WaitingRoomBase.vue index 41eb7e5..5eb0074 100644 --- a/src/desktop/views/room/WaitingRoomBase.vue +++ b/src/desktop/views/room/WaitingRoomBase.vue @@ -100,7 +100,6 @@ const router = useRouter() const gameHub = useGameHubStore() const user = useUserStore() -const userId = user.userInfo?.id || '' const roomId = Array.isArray(route.params.roomId) ? route.params.roomId.join(',') : route.params.roomId const isHost = ref(false) @@ -130,7 +129,7 @@ async function gameInfoListener(response: SignalrResponse) { } const playerList = response.PlayerList - isHost.value = response.Game.CreatorId == userId + isHost.value = response.Game.CreatorId == (user.userInfo?.id || '') hostId.value = response.Game.CreatorId players.value = playerList.map((p: SignalrResponse) => { const avatar = p.UserAvatar ? p.UserAvatar : '/avatar.webp' @@ -166,7 +165,7 @@ async function playerLeftListener(response: SignalrResponse) { players.value = players.value.filter((p) => p.id !== playerId) // 如果是自己被踢,弹出提示并返回首页 - if (playerId == userId && method == 'Kicked') { + if (playerId == user.userInfo?.id || '' && method == 'Kicked') { await toast('您已被房主踢出房间', 'warning') //弹回首页 user.currentRoomId = null diff --git a/src/mobile/components/ChatBoard.vue b/src/mobile/components/ChatBoard.vue index 09ca294..225ffee 100644 --- a/src/mobile/components/ChatBoard.vue +++ b/src/mobile/components/ChatBoard.vue @@ -4,7 +4,7 @@ - +