update:修复日志和防抖
This commit is contained in:
@@ -15,7 +15,7 @@ import {
|
||||
getReadyAPI,
|
||||
kickPlayerAPI,
|
||||
} from "@/apis";
|
||||
import { isLimitError } from "@/util";
|
||||
import { debounce, isLimitError } from "@/util";
|
||||
import { MESSAGETYPES, MESSAGETYPESV2 } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
@@ -59,6 +59,7 @@ const allReady = ref(false);
|
||||
const timer = ref(null);
|
||||
const goBattle = ref(false);
|
||||
const showLimitModal = ref(false);
|
||||
const readySubmitting = ref(false);
|
||||
/** 从结算页返回时为 true,跳过进场靶纸语音 */
|
||||
const skipTargetAudio = ref(false);
|
||||
|
||||
@@ -139,17 +140,22 @@ async function refreshRoomData() {
|
||||
// timer.value = setTimeout(refreshRoomData, 2000);
|
||||
}
|
||||
|
||||
const getReady = async () => {
|
||||
const getReady = debounce(async () => {
|
||||
if (readySubmitting.value) return;
|
||||
readySubmitting.value = true;
|
||||
try {
|
||||
await getReadyAPI(roomNumber.value);
|
||||
ready.value = true;
|
||||
} catch (error) {
|
||||
if (isLimitError(error)) {
|
||||
showLimitModal.value = true;
|
||||
return;
|
||||
}
|
||||
console.log("room ready error", error);
|
||||
} finally {
|
||||
readySubmitting.value = false;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
const closeLimitModal = () => {
|
||||
showLimitModal.value = false;
|
||||
@@ -465,7 +471,10 @@ onBeforeUnmount(() => {
|
||||
<PlayerSeats v-if="room.battleType === 2" :total="room.count || 10" :players="players"
|
||||
:removePlayer="removePlayer" :isOwner="owner.id === user.id" />
|
||||
<view>
|
||||
<SButton :disabled="!canClick" :onClick="() => $clickSound(getReady)">
|
||||
<SButton
|
||||
:disabled="!canClick || readySubmitting"
|
||||
:onClick="() => { $clickSound(); return getReady(); }"
|
||||
>
|
||||
{{
|
||||
allReady.value
|
||||
? "即将进入对局..."
|
||||
|
||||
Reference in New Issue
Block a user