个人练习流程优化

This commit is contained in:
kron
2025-06-25 18:41:30 +08:00
parent 80ba77a653
commit 664678cba0
9 changed files with 94 additions and 56 deletions

View File

@@ -17,15 +17,16 @@ const store = useStore();
const { user } = storeToRefs(store);
const { updateUser } = store;
const start = ref(false);
const showScore = ref(false);
const scores = ref([]);
const total = 12;
const currentRound = ref(0);
const practiseResult = ref({});
const power = ref(0);
const practiseId = ref("");
const onReady = async () => {
await createPractiseAPI(total);
const result = await createPractiseAPI(total);
if (result) practiseId.value = result.id;
currentRound.value = 0;
scores.value = [];
start.value = true;
@@ -40,17 +41,16 @@ async function onReceiveMessage(messages = []) {
currentRound.value = 1;
}
power.value = msg.target.battery;
if (scores.value.length === total) {
showScore.value = true;
}
}
if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
start.value = false;
practiseResult.value = {
...msg.practice,
arrows: JSON.parse(msg.practice.arrows),
};
generateCanvasImage("shareCanvas", 2, user.value, practiseResult.value);
if (practiseId.value && practiseId.value === msg.practice.id) {
start.value = false;
practiseResult.value = {
...msg.practice,
arrows: JSON.parse(msg.practice.arrows),
};
generateCanvasImage("shareCanvas", 2, user.value, practiseResult.value);
}
}
});
}
@@ -101,9 +101,9 @@ onUnmounted(() => {
/>
<ScorePanel2 v-if="start" :scores="scores.map((s) => s.ring)" />
<ScoreResult
v-if="practiseResult.arrows"
:total="total"
:rowCount="6"
:show="showScore"
:onClose="onComplete"
:result="practiseResult"
/>