try to fix examstore value change between pages, improve & add loading screen
This commit is contained in:
parent
652550a41d
commit
64fe08f749
4 changed files with 52 additions and 22 deletions
|
@ -75,9 +75,11 @@ const abc_model = defineModel();
|
||||||
<style scoped>
|
<style scoped>
|
||||||
label {
|
label {
|
||||||
@apply cursor-pointer flex flex-row gap-2 items-center;
|
@apply cursor-pointer flex flex-row gap-2 items-center;
|
||||||
}
|
&:hover {
|
||||||
|
|
||||||
label:hover {
|
|
||||||
@apply bg-slate-200;
|
@apply bg-slate-200;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
span {
|
||||||
|
@apply text-lg;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -101,6 +101,11 @@ async function next() {
|
||||||
}
|
}
|
||||||
if (countAdvanced.value + 1 < dataAdvanced.value?.length!) {
|
if (countAdvanced.value + 1 < dataAdvanced.value?.length!) {
|
||||||
countAdvanced.value++;
|
countAdvanced.value++;
|
||||||
|
useHead({
|
||||||
|
title: `Pytanie ${countAdvanced.value + 1}/${
|
||||||
|
dataAdvanced.value?.length
|
||||||
|
}`,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (countAdvanced.value == dataAdvanced.value?.length! - 1) {
|
if (countAdvanced.value == dataAdvanced.value?.length! - 1) {
|
||||||
ending.value = true;
|
ending.value = true;
|
||||||
|
@ -110,12 +115,13 @@ async function next() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function endExam() {
|
function endExam() {
|
||||||
|
loading.value = true;
|
||||||
while (!ending.value) {
|
while (!ending.value) {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
examStore.result = result.value;
|
examStore.setResult(result.value);
|
||||||
examStore.end = true;
|
examStore.setEnd(true);
|
||||||
return navigateTo("/result", { replace: true });
|
return navigateTo("/result", { replace: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,10 +155,12 @@ const result: Ref<ResultEndType> = ref({
|
||||||
basic: [],
|
basic: [],
|
||||||
advanced: [],
|
advanced: [],
|
||||||
});
|
});
|
||||||
|
const loading = ref(false);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
<Loading v-if="loading" />
|
||||||
<div v-if="statusBasic === 'success' && statusAdvanced === 'success'">
|
<div v-if="statusBasic === 'success' && statusAdvanced === 'success'">
|
||||||
<div class="grid grid-cols-4 min-h-dvh">
|
<div class="grid grid-cols-4 min-h-dvh">
|
||||||
<div class="col-span-3 flex flex-col gap-4">
|
<div class="col-span-3 flex flex-col gap-4">
|
||||||
|
|
|
@ -14,20 +14,24 @@ const categories = [
|
||||||
"PT",
|
"PT",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
const examStore = useExamStore();
|
const examStore = useExamStore();
|
||||||
|
|
||||||
function setAndGo(category: string) {
|
function setAndGo(category: string) {
|
||||||
examStore.category = category;
|
loading.value = true;
|
||||||
|
examStore.setCategory(category);
|
||||||
return navigateTo("/exam");
|
return navigateTo("/exam");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="text-3xl">
|
<div>
|
||||||
|
<div v-if="!loading" class="text-3xl">
|
||||||
<span>Test na prawo jazdy</span>
|
<span>Test na prawo jazdy</span>
|
||||||
<p>
|
<p>
|
||||||
Witaj w teście na prawo jazdy, aby rozpocząć, naciśnij jeden z poniższych
|
Witaj w teście na prawo jazdy, aby rozpocząć, naciśnij jeden z
|
||||||
przycisków:
|
poniższych przycisków:
|
||||||
<br />
|
<br />
|
||||||
</p>
|
</p>
|
||||||
<div class="flex flex-row flex-wrap gap-2">
|
<div class="flex flex-row flex-wrap gap-2">
|
||||||
|
@ -40,4 +44,6 @@ function setAndGo(category: string) {
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<Loading v-else />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -18,12 +18,26 @@ export const useExamStore = defineStore("exam-store", () => {
|
||||||
advanced: [],
|
advanced: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
function setEnd(value: boolean) {
|
||||||
|
end.value = value;
|
||||||
|
return end.value;
|
||||||
|
}
|
||||||
|
function setCategory(value: string) {
|
||||||
|
category.value = value;
|
||||||
|
return category.value;
|
||||||
|
}
|
||||||
|
function setResult(value: ResultEndType) {
|
||||||
|
result.value = value;
|
||||||
|
return result.value;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
category,
|
category,
|
||||||
end,
|
end,
|
||||||
result,
|
result,
|
||||||
resetExam,
|
resetExam,
|
||||||
mildReset,
|
mildReset,
|
||||||
|
setEnd,
|
||||||
|
setCategory,
|
||||||
|
setResult,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue