This commit is contained in:
Alex committed 2025-01-13 14:57:55 +03:00
1 parent b829574822
commit 9c97a6649b
5 files changed
+138 -45

No files matched your search

@@ -0,0 +1,76 @@
<template>
<div class="px-4">
{{ displayDays + declOfNum(displayDays, [' день', ' дня', ' дней']) }}
{{ displayHours + declOfNum(displayHours, [' час', ' часа', ' часов']) }}
{{ displayMinutes + declOfNum(displayMinutes, [' минута', ' минуты', ' минут']) }}
{{ displaySeconds + declOfNum(displaySeconds, [' секунда', ' секунды', ' секунд']) }}
</div>
</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
})
function declOfNum(value, titles) {
const cases = [2, 0, 1, 1, 1, 2]
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]]
}
function countDown() {
const timer = setInterval(() => {
const date = new Date()
const distance = props.endTime.getTime() - date.getTime()
if (distance < 0) {
clearInterval(timer)
return
}
displayDays.value = Math.floor(distance / days.value)
displayHours.value = Math.floor((distance % days.value) / hours.value)
displayMinutes.value = Math.floor((distance % hours.value) / minutes.value)
displaySeconds.value = Math.floor((distance % minutes.value) / seconds)
}, 1000)
}
countDown()
return {
displayMinutes,
displayHours,
displayDays,
displaySeconds,
declOfNum,
}
}
}
</script>
+41 -41
View File
@@ -1,44 +1,38 @@
<template>
<v-container>
<v-row dense justify="center">
<v-card class="bg-red-darken-2 py-5">
<v-card-title class="text-uppercase"> До окончания голосования осталось: </v-card-title>
<v-row dense class="align-baseline justify-center">
<v-col cols="2" class="text-center">
<v-card class="bg-yellow-darken-4">
<v-card-title>{{ displayDays }}</v-card-title>
</v-card>
</v-col>
<div>:</div>
<v-col cols="2" class="text-center">
<v-card class="bg-yellow-darken-4">
<v-card-title>{{ displayHours }}</v-card-title>
</v-card>
</v-col>
<div>:</div>
<v-col cols="2" class="text-center">
<v-card class="bg-yellow-darken-4">
<v-card-title>{{ displayMinutes }}</v-card-title>
</v-card>
</v-col>
<div>:</div>
<v-col cols="2" class="text-center">
<v-card class="bg-yellow-darken-4">
<v-card-title>{{ displaySeconds }}</v-card-title>
</v-card>
</v-col>
</v-row>
<v-row dense class="justify-center">
<v-card-subtitle opacity="false" class="text-uppercase">
{{ displayDays == 1 ? 'День' : displayDays > 1 && displayDays <= 4 ? 'Дня' : displayDays <= 0 ? 'Дней' : 'Дней'}}
</v-card-subtitle>
<v-card-subtitle opacity="false" class="text-uppercase">Часов</v-card-subtitle>
<v-card-subtitle opacity="false" class="text-uppercase">Минут</v-card-subtitle>
<v-card-subtitle opacity="false" class="text-uppercase">Секунд</v-card-subtitle>
</v-row>
</v-card>
</v-row>
</v-container>
<v-row justify="center mb-1">
<v-card class="py-1" variant="otlined">
<v-card-title> До окончания голосования осталось: </v-card-title>
<v-row dense class="align-baseline justify-center">
<v-col cols="2" class="text-center">
<v-card class="bg-yellow-darken-4">
<v-card-title>{{ displayDays }}</v-card-title>
</v-card>
<span class="text-caption">{{ declOfNum(displayDays, [' день', ' дня', ' дней']) }}</span>
</v-col>
<v-col cols="auto">:</v-col>
<v-col cols="2" class="text-center">
<v-card class="bg-yellow-darken-4">
<v-card-title>{{ displayHours }}</v-card-title>
</v-card>
<span class="text-caption">{{ declOfNum(displayHours, [' час', ' часа', ' часов']) }}</span>
</v-col>
<v-col cols="auto">:</v-col>
<v-col cols="2" class="text-center">
<v-card class="bg-yellow-darken-4">
<v-card-title>{{ displayMinutes }}</v-card-title>
</v-card>
<span class="text-caption">{{ declOfNum(displayMinutes, [' минута', ' минуты', ' минут']) }}</span>
</v-col>
<v-col cols="auto">:</v-col>
<v-col cols="2" class="text-center">
<v-card class="bg-yellow-darken-4">
<v-card-title>{{ displaySeconds }}</v-card-title>
</v-card>
<span class="text-caption">{{ declOfNum(displaySeconds, [' секунда', ' секунды', ' секунд']) }}</span>
</v-col>
</v-row>
</v-card>
</v-row>
</template>
<script>
import { computed, ref } from 'vue'
@@ -70,7 +64,12 @@ export default {
const days = computed(() => {
return hours.value * 24
})
console.log(days.value);
function declOfNum(value, titles) {
const cases = [2, 0, 1, 1, 1, 2]
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]]
}
function countDown() {
const timer = setInterval(() => {
const date = new Date()
@@ -101,6 +100,7 @@ export default {
displayHours,
displayDays,
displaySeconds,
declOfNum,
}
}
}
+6
View File
@@ -152,6 +152,12 @@ const routes = [
component: () =>
import("@/views/VoteHomePage.vue")
},
{
path: '/secret',
name: 'Secret Page',
component: () =>
import("@/views/secret/SecretPage.vue")
}
],
},
];
+8 -2
View File
@@ -32,8 +32,9 @@
Окончание: {{ formatDate(voting.endDate) }}
</v-card-subtitle>
<v-card-text>
Осталось: {{ timeRemaining(voting.endDate) }}
Осталось до окончания голосования:
</v-card-text>
<TimerUI :endTime="endTimeOfVote"/>
<v-card-actions class="justify-space-between">
<v-btn
v-if="!voting.voted"
@@ -120,9 +121,11 @@
<script>
import {computed, ref} from "vue";
import VoteConstructor from "@/views/VoteConstructor.vue";
import SmallTimer from "@/components/secret/SmallTimer.vue";
import TimerUI from "@/components/secret/TimerUI.vue";
export default {
components: {VoteConstructor},
components: { VoteConstructor, SmallTimer, TimerUI },
setup() {
const currentTab = ref("current");
const votes = ref([
@@ -199,6 +202,8 @@ export default {
votes.value = votes.value.filter((v) => v.id !== id);
};
const endTimeOfVote = new Date(2025, 0, 14, 15, 58, 5)
return {
currentTab,
votes,
@@ -215,6 +220,7 @@ export default {
openResultsModal,
closeResultsModal,
deleteVoting,
endTimeOfVote,
};
},
};
+7 -2
View File
@@ -1,16 +1,21 @@
<template>
<TimerUI :endTime="end" />
<v-container>
<TimerUI :endTime="end" />
<SmallTimer :endTime="end"/>
</v-container>
</template>
<script>
import TimerUI from "@/components/secret/TimerUI.vue"
import SmallTimer from "@/components/secret/SmallTimer.vue"
export default {
components: {
TimerUI,
SmallTimer,
},
setup() {
const end = new Date(2025, 0, 16, 13, 2, 59)
const end = new Date(2025, 0, 14, 15, 58, 5)
return {
end