细节优化
This commit is contained in:
@@ -90,6 +90,7 @@ async function onReceiveMessage(content) {
|
||||
messages.forEach((msg) => {
|
||||
if (
|
||||
msg.roomNumber === roomNumber.value ||
|
||||
(battleId.value && msg.id === battleId.value) ||
|
||||
msg.constructor === MESSAGETYPES.WaitForAllReady
|
||||
) {
|
||||
console.log("收到消息:", msg);
|
||||
@@ -104,6 +105,7 @@ async function onReceiveMessage(content) {
|
||||
battleId.value = msg.id;
|
||||
redTeam.value = msg.groupUserStatus.redTeam;
|
||||
blueTeam.value = msg.groupUserStatus.blueTeam;
|
||||
step.value = 2;
|
||||
}
|
||||
if (msg.roomNumber === roomNumber.value) {
|
||||
if (msg.constructor === MESSAGETYPES.UserEnterRoom) {
|
||||
@@ -115,7 +117,7 @@ async function onReceiveMessage(content) {
|
||||
};
|
||||
}
|
||||
}
|
||||
if (!start && msg.constructor === MESSAGETYPES.UserExitRoom) {
|
||||
if (!start.value && msg.constructor === MESSAGETYPES.UserExitRoom) {
|
||||
if (room.value.battleType === 1 && room.value.count === 2) {
|
||||
opponent.value = {
|
||||
id: "",
|
||||
@@ -127,6 +129,7 @@ async function onReceiveMessage(content) {
|
||||
title: "房间已解散",
|
||||
icon: "none",
|
||||
});
|
||||
roomNumber.value = "";
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1000);
|
||||
@@ -185,9 +188,9 @@ onMounted(() => {
|
||||
|
||||
onUnmounted(() => {
|
||||
uni.$off("socket-inbox", onReceiveMessage);
|
||||
if (owner.value) {
|
||||
if (owner.value.id === user.value.id) {
|
||||
destroyRoomAPI(roomNumber.value);
|
||||
} else {
|
||||
} else if (roomNumber.value) {
|
||||
exitRoomAPI(roomNumber.value);
|
||||
}
|
||||
});
|
||||
@@ -232,7 +235,7 @@ onUnmounted(() => {
|
||||
v-if="
|
||||
user.id === owner.id && room.battleType === 1 && room.count === 2
|
||||
"
|
||||
:disabled="!opponent"
|
||||
:disabled="!opponent.id"
|
||||
:onClick="startGame"
|
||||
>进入对战</SButton
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user