练习结果完善
This commit is contained in:
@@ -14,6 +14,8 @@ const start = ref(false);
|
||||
const showScore = ref(false);
|
||||
const scores = ref([]);
|
||||
const total = 12;
|
||||
const practiseResult = ref({});
|
||||
const power = ref(0);
|
||||
|
||||
const onReady = async () => {
|
||||
const result = await createPractiseAPI(total);
|
||||
@@ -25,11 +27,17 @@ const onReady = async () => {
|
||||
messages.forEach((msg) => {
|
||||
if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
||||
scores.value.push(msg.target);
|
||||
power.value = msg.target.battery;
|
||||
if (scores.value.length === total) {
|
||||
showScore.value = true;
|
||||
websocket.closeWebSocket();
|
||||
}
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
|
||||
practiseResult.value = {
|
||||
...msg.practice,
|
||||
arrows: JSON.parse(msg.practice.arrows),
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -58,7 +66,7 @@ onUnmounted(() => {
|
||||
:totalRound="total"
|
||||
:currentRound="scores.length + 1"
|
||||
avatar="../static/avatar.png"
|
||||
:power="45"
|
||||
:power="power"
|
||||
:scores="scores"
|
||||
/>
|
||||
<ScorePanel2 v-if="start" :scores="scores.map((s) => s.ring)" />
|
||||
@@ -67,7 +75,7 @@ onUnmounted(() => {
|
||||
:rowCount="6"
|
||||
:show="showScore"
|
||||
:onClose="() => (showScore = false)"
|
||||
:scores="scores.map((s) => s.ring)"
|
||||
:result="practiseResult"
|
||||
/>
|
||||
<SButton v-if="!start" :onClick="onReady">准备好了,直接开始</SButton>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user