feat: create UI Timer, secret page
This commit is contained in:
1 parent
9d350fdbb9
commit
3045a04fd1
4 files changed
+127
-1
No files matched your search
@@ -0,0 +1,100 @@
|
||||
<template>
|
||||
<v-container>
|
||||
<v-row dense justify="center">
|
||||
<v-card class="bg-red-darken-2">
|
||||
<v-card-title> До окончания голосования осталось: </v-card-title>
|
||||
<v-row dense>
|
||||
<v-col>
|
||||
<v-card>
|
||||
<v-card-title>{{ displayDays }}</v-card-title>
|
||||
</v-card>
|
||||
<v-card-subtitle>Дней</v-card-subtitle>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-card>
|
||||
<v-card-title>{{ displayHours }}</v-card-title>
|
||||
</v-card>
|
||||
<v-card-subtitle>Часов</v-card-subtitle>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-card>
|
||||
<v-card-title>{{ displayMinutes }}</v-card-title>
|
||||
</v-card>
|
||||
<v-card-subtitle>Минут</v-card-subtitle>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-card>
|
||||
<v-card-title>{{ displaySeconds }}</v-card-title>
|
||||
</v-card>
|
||||
<v-card-subtitle>Секунд</v-card-subtitle>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</template>
|
||||
<script>
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
endTime: {
|
||||
type: Date,
|
||||
default: () => { return new Date.setFullYear() }
|
||||
}
|
||||
},
|
||||
|
||||
setup(props) {
|
||||
|
||||
const seconds = 1000
|
||||
const displayMinutes = ref(0);
|
||||
const displayHours = ref(0);
|
||||
const displayDays = ref(0);
|
||||
const displaySeconds = ref(0)
|
||||
|
||||
const minutes = computed(() => {
|
||||
return seconds * 60
|
||||
})
|
||||
|
||||
const hours = computed(() => {
|
||||
return minutes.value * 60
|
||||
})
|
||||
|
||||
const days = computed(() => {
|
||||
return hours.value * 24
|
||||
})
|
||||
console.log(days.value);
|
||||
function countDown() {
|
||||
const timer = setInterval(() => {
|
||||
const date = new Date()
|
||||
const distance = props.endTime.getTime() - date.getTime()
|
||||
|
||||
if (distance < 0) {
|
||||
clearInterval(timer)
|
||||
return
|
||||
}
|
||||
|
||||
const daysOf = Math.floor(distance / days.value)
|
||||
const hoursOf = Math.floor((distance % days.value) / hours.value)
|
||||
const minutesOf = Math.floor((distance % hours.value) / minutes.value)
|
||||
const secondsOf = Math.floor((distance % minutes.value) / seconds)
|
||||
|
||||
displayDays.value = daysOf
|
||||
displayHours.value = minutesOf < 10 & minutesOf > 10 ? "0" + hoursOf : hoursOf
|
||||
displayMinutes.value = minutesOf < 10 ? "0" + minutesOf : minutesOf
|
||||
displaySeconds.value = minutesOf < 10 ? "0" + secondsOf : secondsOf
|
||||
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
countDown()
|
||||
|
||||
return {
|
||||
displayMinutes,
|
||||
displayHours,
|
||||
displayDays,
|
||||
displaySeconds,
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -147,6 +147,12 @@ const routes = [
|
||||
component: () =>
|
||||
import("@/views/Vote.vue")
|
||||
},
|
||||
{
|
||||
path: "/secret",
|
||||
name: "Secret Page",
|
||||
component: () =>
|
||||
import("@/views/secret/SecretPage.vue")
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<TimerUI :endTime="end" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TimerUI from "@/components/secret/TimerUI.vue"
|
||||
|
||||
export default {
|
||||
components: {
|
||||
TimerUI,
|
||||
},
|
||||
setup() {
|
||||
const end = new Date(2025, 0, 12, 23, 59, 59)
|
||||
|
||||
return {
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user