display loading when reloading

This commit is contained in:
Julien Calixte
2023-07-20 12:51:08 +02:00
parent 793a45e3df
commit bd4cfc1eda

View File

@@ -1,8 +1,10 @@
<script setup lang="ts">
import LiteLoading from '@/components/LiteLoading.vue'
import { useRegisterSW } from 'virtual:pwa-register/vue'
import { ref } from 'vue'
const devMode = ref(import.meta.env.DEV)
const isLoading = ref(false)
const { offlineReady, needRefresh, updateServiceWorker } = useRegisterSW()
const close = async () => {
@@ -10,6 +12,11 @@ const close = async () => {
needRefresh.value = false
devMode.value = false
}
const reload = () => {
isLoading.value = true
updateServiceWorker()
}
</script>
<template>
@@ -25,12 +32,9 @@ const close = async () => {
</span>
</div>
<div class="buttons">
<button
class="button is-primary"
v-if="needRefresh"
@click="updateServiceWorker()"
>
Reload
<button class="button is-primary" v-if="needRefresh" @click="reload">
<LiteLoading v-if="isLoading" />
<span v-else>Reload</span>
</button>
<button class="button" @click="close">Close</button>
</div>