Skip to content

Commit

Permalink
store
Browse files Browse the repository at this point in the history
  • Loading branch information
hsyhhssyy committed Jun 25, 2024
1 parent ffd83fa commit e43fa0e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
9 changes: 4 additions & 5 deletions src/desktop/components/ChatBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
>
<n-avatar
:src="item.avatar"
size="large"
v-if="userId !== item.userId"
v-if=" (user.userInfo?.id || '') !== item.userId"
:img-props="{ referrerpolicy: 'no-referrer' }"
/>
<n-space vertical :size="0" :align="userId === item.userId ? 'end' : 'start'">
<n-space vertical :size="0" :align=" (user.userInfo?.id || '') === item.userId ? 'end' : 'start'">
{{ item.nickname }}
<n-card class="message-content" size="small">
<component :is="item.content" v-if="item.isComponent" />
Expand All @@ -25,7 +25,7 @@
<n-avatar
:src="item.avatar"
size="large"
v-if="userId === item.userId"
v-if=" (user.userInfo?.id || '') === item.userId"
:img-props="{ referrerpolicy: 'no-referrer' }"
/>
</n-space>
Expand Down Expand Up @@ -72,7 +72,6 @@ const props = defineProps<ChatProps>()
const gameHub = useGameHubStore()
const user = useUserStore()
const userId = user.userInfo?.id || ''
const messages = ref<Message[]>([])
const inputMessage = ref('')
const chatBoard = ref()
Expand Down
4 changes: 4 additions & 0 deletions src/desktop/views/room/JoinRoom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ async function initJoinRoom() {
gameHub.addGameHubListener('PlayerJoined', gameJoinListener)
//JoinRoom是在主界面的
//TODO 此处一定不会有user.currentRoomId
//需要从服务器获取!
//能走到这里,那么服务器已经连上了
if (user.currentRoomId) {
// 重连检查
Expand Down
5 changes: 2 additions & 3 deletions src/desktop/views/room/WaitingRoomBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions src/mobile/components/ChatBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<n-input class="chat-input" :placeholder="props.placeholder || '输入干员名称...'" v-model:value="inputMessage"
@keydown.enter="sendMessage" />
<icon-button class="chat-button" :icon="SendOne" type="success" @click="sendMessage"></icon-button>
<n-popover trigger="manual" :show="currentMessage?.show" width="300px">
<n-popover trigger="manual" :show="currentMessage?.show">
<template #trigger>
<n-badge :value="unreadMessage" :max="99">
<icon-button class="chat-button" :icon="Communication" type="info"
Expand All @@ -26,9 +26,9 @@
<n-card role="dialog" aria-modal="true" class="message-window" embedded size="small">
<div style="height: 100%; overflow: auto;" ref="chatBoard">
<n-flex style="margin-bottom: 5px" v-for="(item, index) in messages" :key="index" :wrap="false"
:justify="userId === item.userId ? 'end' : 'start'">
:justify=" (user.userInfo?.id || '') === item.userId ? 'end' : 'start'">
<n-flex>
<n-avatar :src="item.avatar" size="large" v-if="userId !== item.userId"
<n-avatar :src="item.avatar" size="large" v-if=" (user.userInfo?.id || '') !== item.userId"
:img-props="{ referrerpolicy: 'no-referrer' }" />
</n-flex>
<div class="message-card-with-name">
Expand All @@ -39,7 +39,7 @@
</n-card>
</div>
<n-flex>
<n-avatar :src="item.avatar" size="large" v-if="userId === item.userId"
<n-avatar :src="item.avatar" size="large" v-if=" (user.userInfo?.id || '') === item.userId"
:img-props="{ referrerpolicy: 'no-referrer' }" />
</n-flex>
</n-flex>
Expand Down Expand Up @@ -83,7 +83,6 @@ const emits = defineEmits<{
const gameHub = useGameHubStore()
const user = useUserStore()
const userId = user.userInfo?.id || ''
const messages = ref<Message[]>([])
const inputMessage = ref('')
const chatBoard = ref()
Expand Down
2 changes: 2 additions & 0 deletions src/mobile/views/game/CypherChallenge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ onUnmounted(() => {
position: relative;
overflow: hidden;

max-width: 1000px;

.game-panel {
height: 100%;
background: url(@/assets/images/cypherChallenge/loading.jpg) center / cover no-repeat;
Expand Down
5 changes: 2 additions & 3 deletions src/mobile/views/room/WaitingRoomBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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)
Expand Down Expand Up @@ -123,7 +122,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'
Expand Down Expand Up @@ -152,7 +151,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')
}
}
Expand Down

0 comments on commit e43fa0e

Please sign in to comment.