Loading.vue 1.78 KB
Newer Older
BigBigC's avatar
BigBigC committed
1 2 3 4 5
<template>
	<div class="loading" v-if="showLoading">
		<div class="running-con">
			<img src="../assets/images/running.gif" mode=""></img>
			<p>RUNNING...</p>
web's avatar
web committed
6 7
			<p>ETA: {{ formatTime(timeLeft) }}</p>

BigBigC's avatar
BigBigC committed
8 9 10 11 12
		</div>
	</div>
</template>

<script setup>
web's avatar
web committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
import { ref, onMounted, onUnmounted } from 'vue';

const props = defineProps({
	showLoading: {
		type: Boolean,
		default: false
	}
});

const timeLeft = ref(30);
let timer;

const startCountdown = () => {
	timer = setInterval(() => {
		if (timeLeft.value > 0) {
			timeLeft.value--;
		} else {
			clearInterval(timer);
BigBigC's avatar
BigBigC committed
31
		}
web's avatar
web committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
	}, 1000);
};

const formatTime = (seconds) => {
	const hours = Math.floor(seconds / 3600);
	const minutes = Math.floor((seconds % 3600) / 60);
	const secs = seconds % 60;
	return `${padZero(hours)}:${padZero(minutes)}:${padZero(secs)}`;
};

const padZero = (num) => {
	return num.toString().padStart(2, '0');
};


onMounted(() => {
	startCountdown()
})

onUnmounted(() => {
	clearInterval(timer);
})



BigBigC's avatar
BigBigC committed
57 58 59
</script>

<style>
web's avatar
web committed
60
.loading {
BigBigC's avatar
BigBigC committed
61 62 63 64 65 66 67 68 69 70 71 72 73
	position: fixed;
	top: 0;
	left: 0;
	z-index: 100;
	height: 100%;
	width: 100%;
	background: #FFFFFF;
	opacity: 0.93;
	display: flex;
	justify-content: center;
	align-items: center;
}

web's avatar
web committed
74
.running-con {
BigBigC's avatar
BigBigC committed
75 76 77 78 79 80
	width: 56vw;
	height: 25.07vw;
	background: #000000;
	border-radius: 4.27vw;
	border: .13vw solid #707070;
	display: flex;
web's avatar
web committed
81 82 83
	flex-direction: column;
	justify-content: flex-end;
	align-items: center;
BigBigC's avatar
BigBigC committed
84 85 86 87 88
	position: relative;
	padding: 5.6vw 0;
	box-sizing: border-box;
}

web's avatar
web committed
89
.running-con img {
BigBigC's avatar
BigBigC committed
90 91 92 93 94 95 96 97
	width: 22.4vw;
	height: 38.4vw;
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	top: -28vw;
}

web's avatar
web committed
98
.running-con p {
BigBigC's avatar
BigBigC committed
99 100 101 102 103 104 105
	font-family: Roboto-Bold;
	font-weight: bold;
	font-size: 3.73vw;
	color: #FFFFFF;
	text-align: center;
	font-style: normal;
	text-transform: none;
web's avatar
web committed
106
	display: flex;
BigBigC's avatar
BigBigC committed
107 108 109
	/* margin-top: 32rpx; */
}
</style>