<template>
<GLoading class="gl-loading" :stage="7 * 4" :parts="parts" />
<GButton class="w-200 mg-10 bk" type="shrink" icon="round" balance @click="onLoading">Loading</GButton>
</template>
<script setup>
import { ref } from 'vue';
const parts = ref(0)
const timeout = ref(0)
const waiting = [{
wait: 0,
parts: 0
}, {
wait: 100,
parts: 1
}, {
wait: 1000,
parts: 9
},{
wait: 500,
parts: 14
},{
wait: 1000,
parts: 26
},{
wait: 2500,
parts: 28
}]
const onLoading = (i = 0) => {
if (i === 0) clearTimeout(timeout)
const time = waiting[i]
if (time) {
parts.value = time.parts
timeout.value = setTimeout(() => {
onLoading(i + 1)
}, time.wait*5)
}
}
</script>