调试多v多房间功能

This commit is contained in:
kron
2026-02-05 18:06:55 +08:00
parent 93c549109f
commit 4cfa097cc8
7 changed files with 32 additions and 121 deletions

View File

@@ -114,8 +114,8 @@ const refreshMembers = (members = []) => {
players.value[index] = { ...m.userInfo, groupType: m.groupType };
if (m.groupType === 1) {
blueTeam.value.push({ ...m.userInfo, groupType: 1 });
} else if (m.groupType === 0) {
redTeam.value.push({ ...m.userInfo, groupType: 0 });
} else if (m.groupType === 2) {
redTeam.value.push({ ...m.userInfo, groupType: 2 });
}
});
for (let i = 0; i < room.value.count / 2; i++) {
@@ -165,12 +165,6 @@ async function onReceiveMessage(message) {
}
const chooseTeam = async (team) => {
if (team !== 2) {
const notInTeam = room.value.members.some(
(m) => m.userInfo.id === user.value.id && m.groupType === 2
);
if (!notInTeam) return;
}
const result = await chooseTeamAPI(roomNumber.value, team);
refreshMembers(result.members);
};
@@ -302,45 +296,45 @@ onBeforeUnmount(() => {
<view class="choose-side">
<view>
<view
v-for="(item, index) in blueTeam"
v-for="(item, index) in redTeam"
:key="index"
class="choose-side-left-item"
>
<button
hover-class="none"
v-if="item.id === user.id"
@click="chooseTeam(2)"
@click="chooseTeam(0)"
>
<image src="../static/close-grey.png" mode="widthFix" />
</button>
<text class="truncate">{{ item.name || "我要加入" }}</text>
<view v-if="item.id">
<Avatar :src="item.avatar" :size="36" />
<text v-if="!!item.state">已准备</text>
<text :style="{ opacity: !!item.state ? 1 : 0 }">已准备</text>
</view>
<button v-else hover-class="none" @click="chooseTeam(1)">
<button v-else hover-class="none" @click="chooseTeam(2)">
<image src="../static/add-grey.png" mode="widthFix" />
</button>
</view>
</view>
<view>
<view
v-for="(item, index) in redTeam"
v-for="(item, index) in blueTeam"
:key="index"
class="choose-side-right-item"
>
<view v-if="item.id">
<Avatar :src="item.avatar" :size="36" />
<text v-if="!!item.state">已准备</text>
<text :style="{ opacity: !!item.state ? 1 : 0 }">已准备</text>
</view>
<button v-else hover-class="none" @click="chooseTeam(0)">
<button v-else hover-class="none" @click="chooseTeam(1)">
<image src="../static/add-grey.png" mode="widthFix" />
</button>
<text class="truncate">{{ item.name || "我要加入" }}</text>
<button
hover-class="none"
v-if="item.id === user.id"
@click="chooseTeam(2)"
@click="chooseTeam(0)"
>
<image src="../static/close-grey.png" mode="widthFix" />
</button>
@@ -479,7 +473,7 @@ onBeforeUnmount(() => {
}
.player .ready {
background-color: #2c261fb3 !important;
border-color: #a3793f66 !important;
border: 1rpx solid #a3793f66 !important;
color: #fed847 !important;
}
.team-mode > view > image:nth-child(2) {
@@ -657,6 +651,7 @@ onBeforeUnmount(() => {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 14rpx;
}
.choose-side-left-item > button:last-child > image,
.choose-side-right-item > button:first-child > image {
@@ -677,7 +672,7 @@ onBeforeUnmount(() => {
margin-top: -16rpx;
position: relative;
background-color: #2c261fb3;
border-color: #a3793f66;
border: 1rpx solid #a3793f66;
color: #fed847;
}
</style>