-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
65 lines (56 loc) · 1.35 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
57
58
59
60
61
62
63
64
65
<template>
<div>
<div class="app overflow-hidden w-screen h-screen-min" :class="{
'hidden': !ready
}">
<NuxtPage />
</div>
<UiCol v-if="!ready" class="app w-screen h-screen-min justify-center">
<p class="mb-6">Loading... {{ c }}%</p>
<div class="mx-10 h-[6px] bg-slate-800">
<div class="h-[6px] bg-cyan-400 transition-all" :style="`width: ${c}%`"></div>
</div>
</UiCol>
</div>
</template>
<script setup>
const config = useRuntimeConfig()
const ready = ref(false)
const c = ref(0)
const characters = 29;
const ships = 17;
const stars = 3;
const images = []
onMounted(async () => {
function loadImage(src) {
return new Promise(resolve => {
const img = new Image()
img.onload = resolve
img.src = src
})
}
for (let i = 1; i <= characters; i++) {
images.push(`/characters/${i}-min.png`)
}
for (let i = 1; i <= ships; i++) {
images.push(`/ships/${i}-min.png`)
}
for (let i = 1; i <= stars; i++) {
images.push(`/stars/${i}.png`)
}
for (let i = 1; i <= config.public.planets; i++) {
images.push(`/planets/${i}-min.png`)
}
for (let i = 0; i < images.length; i++) {
await loadImage(images[i])
c.value = Math.round(i / images.length * 100)
}
ready.value = true
})
</script>
<style scoped>
.app {
background-image: url('@/assets/bg/screen2.jpg');
@apply bg-cover text-white text-center bg-center;
}
</style>