Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: composition api on some pages #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
</NuxtLayout>
</template>

<script lang="ts">
<script lang="ts" setup>
import Logo from '~/components/Logo.vue'
import ArrowRight from '~/components/icons/ArrowRight.vue'
import {useRouter} from "nuxt/app";
const router = useRouter();

export default {
components: {Logo, ArrowRight},
methods: {
goSettings() {
this.$router.push('/settings');
}
}
let goSettings = ():void => {
router.push({name:'settings'})
}

</script>
30 changes: 11 additions & 19 deletions pages/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,22 @@
</NuxtLayout>
</template>

<script lang="ts">
<script lang="ts" setup>
import Wave from '~/components/icons/Wave.vue'
import Single from "~/components/Single.vue";
import {onMounted} from "@vue/runtime-core";
import {useRouter} from "nuxt/app";
import {ref} from "@vue/reactivity";
import {Ref} from "vue";
const router = useRouter()

export default {
async setup() {
const router = useRouter();
onMounted(() => {
router.push('/settings/difficulty');
})

onMounted(() => {
router.push('/settings/difficulty');
})
},
components: {Wave, Single},
data() {
return {
progress_percent: 0
}
},
methods: {
changeProgress(value : number) {
this.progress_percent = value;
}
}
let progress_percent: Ref<Number> = ref(0)

let changeProgress = (value: Number) => {
return progress_percent.value = value
}
</script>
30 changes: 11 additions & 19 deletions pages/settings/difficulty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,22 @@
</ul>
</template>

<script lang="ts">
import {Single} from "#components";
<script lang="ts" setup>
import {useGameStore} from "~/store/game";
import waveAnimation from "~/compositions/animations/wave";
import {Difficult} from "../../types/global";
import { defineEmits } from 'vue'
import {useRouter} from "nuxt/app";
const emit = defineEmits(['progress'])
const router = useRouter()
const gameStore = useGameStore()

export default {
emits: ['progress'],
async setup(props, {emit}) {
const gameStore = useGameStore()
emit('progress', 0)
await waveAnimation();

emit("progress", 0)
let choiceDifficulty = (difficulty: Difficult) => {
gameStore.setDifficulty(difficulty)
router.push('/settings/questions_number')

await waveAnimation();

return { gameStore }
},
components: {Single},
methods: {
async choiceDifficulty(difficulty: Difficult) {
this.gameStore.setDifficulty(difficulty)

this.$router.push('/settings/questions_number');
},
},
}
</script>